From fde98a2d4fbfbb61a164517cd8dba1fd990d5ea4 Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Wed, 23 Nov 1977 12:45:32 -0800 Subject: [PATCH] BSD 1 development Work on file pcs/installpcs Work on file pcs/tables.i Work on file pcs/scanner.i Work on file pcs/READ_ME Work on file lib/READ_ME Work on file etc/winfo Work on file etc/ttywhere Work on file etc/ttytype Work on file fpterp/fp2.s Work on file fpterp/fp3.s Work on file fpterp/fp1.s Work on file fpterp/fpx.s Work on file fpterp/READ_ME Work on file assubs/fcrt0.s Work on file assubs/mcrt0.s Work on file assubs/sep.s Work on file tests/ancestor.p Work on file tests/powersoftwo.p Work on file tests/cntchars.p Work on file tests/palindromes.p Work on file assubs/pcrt0.s Work on file tests/eightqueens.p Work on file tests/numericIO.p Work on file tests/quicksort.p Work on file tests/primes.p Work on file tests/ancestor2.p Work on file tests/t07.p Work on file tests/t09.p Work on file tests/t04.p Work on file tests/insan.d Work on file tests/t02.p Work on file tests/t06.p Work on file tests/pretty.p Work on file tests/t03.p Work on file tests/insan.p Work on file tests/t11.p Work on file tests/t01.p Work on file tests/t10.p Work on file tests/t08.p Work on file tests/t05.p Work on file tests/t15.p Work on file tests/t19.p Work on file tests/t14.p Work on file tests/t16.p Work on file tests/t12.p Work on file tests/t18.p Work on file tests/t13.p Work on file tests/t17.p Work on file man1/su.8 Work on file man1/login.1 Work on file man1/sh.1 Work on file man1/cd.1 Work on file man1/wait.1 Work on file man1/lib.1 Work on file man8/quotfix.8 Work on file man8/glob2.8 Work on file s1/READ_ME Work on file s1/passwd.c Work on file s1/sh.c Work on file s1/who.c Synthesized-from: 1bsd --- assubs/fcrt0.s | 25 + assubs/mcrt0.s | 69 +++ assubs/pcrt0.s | 33 ++ assubs/sep.s | 19 + etc/ttytype | 84 ++++ etc/ttywhere | 81 ++++ etc/winfo | 30 ++ fpterp/READ_ME | 20 + fpterp/fp1.s | 518 +++++++++++++++++++++ fpterp/fp2.s | 194 ++++++++ fpterp/fp3.s | 419 +++++++++++++++++ fpterp/fpx.s | 36 ++ lib/READ_ME | 1 + man1/cd.1 | 25 + man1/lib.1 | 45 ++ man1/login.1 | 60 +++ man1/sh.1 | 363 +++++++++++++++ man1/su.8 | 24 + man1/wait.1 | 32 ++ man8/glob2.8 | 23 + man8/quotfix.8 | 63 +++ pcs/READ_ME | 11 + pcs/installpcs | 5 + pcs/scanner.i | 148 ++++++ pcs/tables.i | 88 ++++ s1/READ_ME | 20 + s1/passwd.c | 219 +++++++++ s1/sh.c | 1069 +++++++++++++++++++++++++++++++++++++++++++ s1/who.c | 89 ++++ tests/ancestor.p | 24 + tests/ancestor2.p | 22 + tests/cntchars.p | 23 + tests/eightqueens.p | 41 ++ tests/insan.d | 5 + tests/insan.p | 346 ++++++++++++++ tests/numericIO.p | 16 + tests/palindromes.p | 17 + tests/powersoftwo.p | 34 ++ tests/pretty.p | 265 +++++++++++ tests/primes.p | 30 ++ tests/quicksort.p | 31 ++ tests/t01.p | 24 + tests/t02.p | 179 ++++++++ tests/t03.p | 31 ++ tests/t04.p | 47 ++ tests/t05.p | 15 + tests/t06.p | 14 + tests/t07.p | 12 + tests/t08.p | 28 ++ tests/t09.p | 19 + tests/t10.p | 29 ++ tests/t11.p | 19 + tests/t12.p | 24 + tests/t13.p | 56 +++ tests/t14.p | 42 ++ tests/t15.p | 16 + tests/t16.p | 21 + tests/t17.p | 20 + tests/t18.p | 12 + tests/t19.p | 55 +++ 60 files changed, 5330 insertions(+) create mode 100644 assubs/fcrt0.s create mode 100644 assubs/mcrt0.s create mode 100644 assubs/pcrt0.s create mode 100644 assubs/sep.s create mode 100644 etc/ttytype create mode 100644 etc/ttywhere create mode 100644 etc/winfo create mode 100644 fpterp/READ_ME create mode 100644 fpterp/fp1.s create mode 100644 fpterp/fp2.s create mode 100644 fpterp/fp3.s create mode 100644 fpterp/fpx.s create mode 100644 lib/READ_ME create mode 100644 man1/cd.1 create mode 100644 man1/lib.1 create mode 100644 man1/login.1 create mode 100644 man1/sh.1 create mode 100644 man1/su.8 create mode 100644 man1/wait.1 create mode 100644 man8/glob2.8 create mode 100644 man8/quotfix.8 create mode 100644 pcs/READ_ME create mode 100644 pcs/installpcs create mode 100644 pcs/scanner.i create mode 100644 pcs/tables.i create mode 100644 s1/READ_ME create mode 100644 s1/passwd.c create mode 100644 s1/sh.c create mode 100644 s1/who.c create mode 100644 tests/ancestor.p create mode 100644 tests/ancestor2.p create mode 100644 tests/cntchars.p create mode 100644 tests/eightqueens.p create mode 100644 tests/insan.d create mode 100644 tests/insan.p create mode 100644 tests/numericIO.p create mode 100644 tests/palindromes.p create mode 100644 tests/powersoftwo.p create mode 100644 tests/pretty.p create mode 100644 tests/primes.p create mode 100644 tests/quicksort.p create mode 100644 tests/t01.p create mode 100644 tests/t02.p create mode 100644 tests/t03.p create mode 100644 tests/t04.p create mode 100644 tests/t05.p create mode 100644 tests/t06.p create mode 100644 tests/t07.p create mode 100644 tests/t08.p create mode 100644 tests/t09.p create mode 100644 tests/t10.p create mode 100644 tests/t11.p create mode 100644 tests/t12.p create mode 100644 tests/t13.p create mode 100644 tests/t14.p create mode 100644 tests/t15.p create mode 100644 tests/t16.p create mode 100644 tests/t17.p create mode 100644 tests/t18.p create mode 100644 tests/t19.p diff --git a/assubs/fcrt0.s b/assubs/fcrt0.s new file mode 100644 index 0000000000..3e5f11ccde --- /dev/null +++ b/assubs/fcrt0.s @@ -0,0 +1,25 @@ +/ C runtime startup +/ with floating point interpreter + +.globl savr5 +.globl fptrap,fpjsr +.globl _exit + +.globl _main + +start: + sys signal; 4; fptrap + jsr pc,fpjsr + setd + mov sp,r0 + mov (r0),-(sp) + tst (r0)+ + mov r0,2(sp) + jsr pc,_main + cmp (sp)+,(sp)+ + mov r0,(sp) + jsr pc,*$_exit + sys exit + +.bss +savr5: .=.+2 diff --git a/assubs/mcrt0.s b/assubs/mcrt0.s new file mode 100644 index 0000000000..2d4872bab1 --- /dev/null +++ b/assubs/mcrt0.s @@ -0,0 +1,69 @@ +/ C runtime startoff including monitoring +/ +/ Modified to work in separate i/d +/ Remove comments below to use without floating point +/ + +cbufs = 150. + +.globl _monitor +.globl _sbrk +.globl _main +.globl _exit +.globl _IEH3exit +.globl _etext +.comm countbase,2 + +.comm savr5,2 + +/.globl fptrap,fpjsr +start: +/ sys signal; 4; fptrap +/ jsr pc,fpjsr + setd + mov sp,r0 + mov (r0),-(sp) + tst (r0)+ + mov r0,2(sp) + + 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)+ + jsr pc,_exit + +9: + mov $2,r0 + sys write; 8f; 9f-8f + +.data; 8: ; 9:.even; .text + +_exit: +_IEH3exit: + mov r5,-(sp) + mov sp,r5 + clr -(sp) + jsr pc,_monitor + tst (sp)+ + mov 4(r5),r0 + sys exit +eprol: diff --git a/assubs/pcrt0.s b/assubs/pcrt0.s new file mode 100644 index 0000000000..0f5c7b7b76 --- /dev/null +++ b/assubs/pcrt0.s @@ -0,0 +1,33 @@ +/ Modified C runtime startoff for pcx +/ with floating point interpreter + +.globl savr5 +.globl fptrap +.globl _exit, _pxpbuf + +.globl _main + +start: + br 1f + 0 + _pxpbuf +1: + sys signal; 4; fptrap + setd + mov sp,r0 + mov (r0),-(sp) + tst (r0)+ + mov r0,2(sp) + jsr pc,_main + cmp (sp)+,(sp)+ + mov r0,(sp) + jsr pc,*$_exit + sys exit + +.bss +savr5: .=.+2 +.data +_info: + _info + 1 + _pxpbuf diff --git a/assubs/sep.s b/assubs/sep.s new file mode 100644 index 0000000000..5d7069bc36 --- /dev/null +++ b/assubs/sep.s @@ -0,0 +1,19 @@ + .globl _sep +_sep: + clr r0 + sys 61. + cmp r0,0 + bne succeed + inc 0 + clr r0 + sys 61. + cmp r0,0 + beq fail + dec 0 +succeed: + mov $1,r0 + rts pc +fail: + dec 0 + clr r0 + rts pc diff --git a/etc/ttytype b/etc/ttytype new file mode 100644 index 0000000000..5ca1c8b9df --- /dev/null +++ b/etc/ttytype @@ -0,0 +1,84 @@ +0du +1du +2du +3du +4du +5du +6l1 +7l1 +8td +9l1 +acl +bca +ccl +dcl +ecl +fcl +gcl +hcl +icl +jcl +kcl +lcl +mcl +ncl +ocl +pcl +qca +rt3 +st3 +tca +vtd +wtd +zca +Acl +Bcl +Cca +Dca +Ecl +Fca +Gcl +Hcl +Ica +Jcl +Kcl +Lcl +Mti +Nti +Opd +Ppd +Qca +Rcl +Scl +Tcl +Uca +Wca +Xca ++ca +%ca +_ca +,ca +ca +ca + +t- terminal (hard copy) + t3 TTY 33/35 + t7 TTY 37 + ti TI 733 + td Decwriter II +c- crt + ch Hazeltine 2000 + cl Lear Siegler + ca Lear Siegler ADM-3a + ct Teleray +g- graphics terminal + g0 GT40 + g2 GT42 +p- plotting terminal + pd DTC + pg GSI +l- computer link + l1 PDP-11/10 + lh HP 2100 +du dial up line +uk unknown diff --git a/etc/ttywhere b/etc/ttywhere new file mode 100644 index 0000000000..81d9304b2e --- /dev/null +++ b/etc/ttywhere @@ -0,0 +1,81 @@ +date last updated: 11/03/77 +tty no location terminal baud rate of 11/70 + +tty0 dial-up 300 +tty1 dial-up 300 +tty2 dial-up 300 +tty3 dial-up 300 +tty4 dial-up 300 +tty5 dial-up 300 +tty6 119B Cory 11/10 2400 +tty7 119B Cory 11/10 2400 +tty9 119B Cory 11/10 2400 +tty8 199B Cory console 300 +ttya 199 Cory adm 9600 +ttyb 199 Cory adm 9600 +ttyc 199 Cory adm 9600 +ttyd 199 Cory adm 9600 +ttye 199 Cory adm 9600 +ttyf 199 Cory adm 9600 +ttyg 199 Cory adm 9600 +ttyh 321 Cory adm 9600 +ttyi 199 Cory adm 9600 +ttyj 199 Cory adm 9600 +ttyk 199 Cory adm 9600 +ttyl 199 Cory adm 9600 +ttym 199 Cory adm 9600 +ttyn 199 Cory adm 9600 +ttyo 199 Cory adm 9600 +ttyp 199 Cory adm 9600 +ttyq Hodges adm 9600 +ttyr 267mCory Stonebraker 9600 +ttys 367 Cory Singer 9600 +ttyt 187mCory Schriebman 9600 +ttyv 119 Cory dec II 300 +ttyw 119 Cory dec II 300 +ttyy 119 Cory 300 +ttyz 119 Cory adm 9600 +tty+ 119 Cory adm 9600 +tty- 119 Cory adm 9600 +tty, 119 Cory adm 9600 +tty. 2400 +tty# Hearst Mining 1200 +tty= 479 Cory White 300 +tty_ +tty% HP 2100 +tty^a Hodges +tty^b +tty^c +tty^e +tty^t 507E Patterson 9600 +tty^u 508jE Library 9600 +tty^v 513E Rowe 9600 +tty^w 567E Kahan 9600 +tty^x 559E Gill 9600 +tty^y 9600 +ttyA 508 Evans adm 9600 +ttyB 508 Evans adm 9600 +ttyC 508 Evans adm 9600 +ttyD 508 Evans adm 9600 +ttyE 508 Evans adm 9600 +ttyF 508 Evans adm 9600 +ttyG 508 Evans adm 9600 +ttyH 508 Evans adm 9600 +ttyI 508 Evans adm 9600 +ttyJ 508 Evans adm 9600 +ttyK 508 Evans adm 9600 +ttyL 508 Evans adm 9600 +ttyM 508 Evans dec II 300 +ttyN 570 Evans ti 300 +ttyO 570 Evans dtc 300 +ttyP 573 Evans dtc 300 +ttyQ 508 Evans adm 9600 +ttyR 508 Evans adm 9600 +ttyS 508 Evans adm 9600 +ttyT 508 Evans adm 9600 +ttyU 501E Fabry 9600 +ttyV 505E Prenner 9600 +ttyW 511E S.Graham 9600 +ttyX 517E Harrison 9600 +ttyY 519E Fateman 9600 +ttyZ 503E Despain 9600 diff --git a/etc/winfo b/etc/winfo new file mode 100644 index 0000000000..0f1f8f4992 --- /dev/null +++ b/etc/winfo @@ -0,0 +1,30 @@ +evans:ABCDFGHIJKLQRST +cory:abcdefgijklmnopvwyz+-, +phone:01234 +11/10:679 +private:58hq.=%MNOPUVWXYZ#!Ehst + +guest:guest*|lhs* +cc:cc-* +154:c54* +153:c53* +254:c254* +292f:c292* +155:c55* +40-1:c401* +40-2:c402* +41-1:c41*|41* +41-2:12* +41-3:13* + +root:0:0 +jeff:11:10 +chuck:25:10 +manual:9:0 +pascal:7:0 +bill:37:10 +kurt:1:10 +ken:12:10 +kridle:30:10 +wu:7:10 +mosher:18:10 diff --git a/fpterp/READ_ME b/fpterp/READ_ME new file mode 100644 index 0000000000..11badf5897 --- /dev/null +++ b/fpterp/READ_ME @@ -0,0 +1,20 @@ +November 13, 1977 + +This directory contains the source for a floating point interpreter +modified to work in separate i/d space with a system call "fetchi" +as described in ../SETUP. The interpreter assumes that the +system call in number 61. + +If you have to add this call because you don't have floating point hardware, +and you cannot make it call 61. you don't have to remake all the Pascal +stuff... simply running the "load" scripts in ../pi, ../pxp and ../px +is sufficient... these don't require that you have a version 7 C compiler. + + Bill Joy + CS Division + Department of EE and CS + UC Berkeley + Berkeley, California 94704 + + (415) 524-4510 [HOME] + (415) 642-4948 [SCHOOL] diff --git a/fpterp/fp1.s b/fpterp/fp1.s new file mode 100644 index 0000000000..dd6ae39580 --- /dev/null +++ b/fpterp/fp1.s @@ -0,0 +1,518 @@ +/ fp1 -- floating point simulator + +rti = 2 +bpt = 3 +fetchi = 61. + +m.ext = 200 / long mode bit +m.lngi = 100 / long integer mode + +.globl fptrap, fpjsr, _reenter +.globl ac0, ac1, ac2, ac3 + +2: + bpl 1f + jsr pc,1f + bis $10,sps + rts pc +1: + bne 1f + jsr pc,1f + bis $4,sps + rts pc +1: + bvc 1f + jsr pc,1f + bis $2,sps + rts pc +1: + bcc 1f + jsr pc,1f + bis $1,sps + rts pc +1: + mov $140000,sps + rts pc +fpjsr: + jsr pc,2b + mov (sp),-(sp) + mov sps,2(sp) + add $2,(sp) +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)+ + sub $8,sp / room for double push + mov r0,-(sp) / ??? + mov (r0),r0 + sub $2,r0 + sys fetchi + mov r0,r5 / instruction + mov (sp)+,r0 / ??? + clr trapins + mov r5,r4 + bic $7777,r4 + cmp r4,$170000 + beq 1f + jmp badins +lookahead: + add $2,spc + mov ssp,sp + sub $8,sp +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 + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0rx; mod242 + .text + br 2f +1: + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0f; mod24f + .text +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 + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0rx; mod242 + .text + br 3f +2: + cmp r2,$5400 + bne 2f + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0ra; mod24i + .text + br 3f +2: + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0f; mod24d + .text + br 3f +1: + mov $0f,r1 + jsr pc,fsrc + .data +0: mod0f; mod24f + .text +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 ret + +sret: + mov $fpsr,r0 + bic $17,(r0) + tst (r5) + bpl 1f + bis $10,(r0) + br ret +1: + bne ret + bis $4,(r0) + +ret: + tst trapins + bne 1f + mov spc,r0 + sys fetchi + mov r0,r5 + mov r5,r4 + bic $7777,r4 + cmp $170000,r4 + jeq lookahead +1: + 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 pc + +mod0ra: + bit $m.lngi,fpsr + bne badi1 + +mod0r: + cmp r3,$ssp + bhis badi1 +mod0rx: + tst (r1)+ + rts pc + +mod1: + cmp r3,$spc + beq badi1 + mov (r3),r3 + br check + +mod2: + cmp r3,$spc + bne 1f +/ $n + mov (r3),r0 + sys fetchi + mov r0,pctmp + mov $2,r0 + add r0,(r3) + mov $pctmp,r3 + br check +/ (rn)+ +1: + mov (r3),-(sp) + jsr pc,*2(r1) + add r0,(r3) + mov (sp)+,r3 + br check + +mod3: + cmp r3,$spc + bne 1f +/ *$n + mov r0,-(sp) + mov (r3),r0 + sys fetchi + add $2,(r3) + mov r0,r3 + mov (sp)+,r0 + br check +/ *(rn)+ +1: + 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 r0,-(sp) + mov spc,r0 + sys fetchi + add $2,spc + add (r3),r0 /shouldn't happen separate i and d !!! + mov r0,r3 + mov (sp)+,r0 + br check + +mod7: + jsr pc,mod6 + mov (r3),r3 + br check + +badi1: + jmp badins + +check: + bit $1,r3 + bne badi1 + rts pc + +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/fpterp/fp2.s b/fpterp/fp2.s new file mode 100644 index 0000000000..62d8c87ecb --- /dev/null +++ b/fpterp/fp2.s @@ -0,0 +1,194 @@ +/ 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: + rts pc + +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: + mov $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 + 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 xoflo + tst r1 + bne xoflo +1: + bit $m.lngi,fpsr + beq 1f + tst asign + bge 2f + neg r3 + adc r2 + bcs 2f + neg r2 +2: + mov r2,(r5) + mov r3,2(r5) + rts pc +1: + tst r2 + bne xoflo + tst asign + bge 2f + neg r3 +2: + mov r3,(r5) + rts pc + +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 + jmp sret + +i.ldfps: + mov (r3),fpsr + jmp ret + +i.stfps: + mov fpsr,(r3) + jmp ret + diff --git a/fpterp/fp3.s b/fpterp/fp3.s new file mode 100644 index 0000000000..e358578c22 --- /dev/null +++ b/fpterp/fp3.s @@ -0,0 +1,419 @@ +/ 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+10,r0 + sub -(r0),r4 + sbc r3 + sbc r2 + sbc r1 + sub -(r0),r3 + sbc r2 + sbc r1 + sub -(r0),r2 + sbc r1 + sub -(r0),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 + bne 3f +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 + +3: + mov $bins,r5 + mov areg,r1 + mov areg+2,r2 + mov areg+4,r3 + mov areg+6,r4 + mov r1,(r5)+ + mov r2,(r5)+ + mov r3,(r5)+ + mov r4,(r5)+ + clc + asl r4 + rol r3 + rol r2 + rol r1 + mov r1,(r5)+ + mov r2,(r5)+ + mov r3,(r5)+ + mov r4,(r5)+ + mov $areg+10,r0 + jsr pc,addr + mov r1,(r5)+ + mov r2,(r5)+ + mov r3,(r5)+ + mov r4,(r5)+ + clr r1 + clr r2 + clr r3 + clr r4 + mov $breg+6,r5 + mov $10,-(sp) +4: + mov (r5),r0 + ror (r5) + ror (r5) + clc + ror r1 + ror r2 + ror r3 + ror r4 + clc + ror r1 + ror r2 + ror r3 + ror r4 + bic $177774,r0 + beq 1f + ash $3,r0 + add $bins,r0 + jsr pc,addr +1: + dec (sp) + bne 4b + cmp r5,$breg+2 + beq 1f + mov $10,(sp) + br 2f +1: + mov $4,(sp) +2: + tst -(r5) + cmp r5,$breg + bhis 4b + tst (sp)+ + clc + ror r1 + ror r2 + ror r3 + ror r4 + mov $areg,r0 + mov r1,(r0)+ + mov r2,(r0)+ + mov r3,(r0)+ + mov r4,(r0)+ + mov (sp)+,r5 + rts pc +addr: + add -(r0),r4 + adc r3 + adc r2 + adc r1 + add -(r0),r3 + adc r2 + adc r1 + add -(r0),r2 + adc r1 + add -(r0),r1 + rts pc +xorsign: + cmp asign,bsign + beq 1f + mov $-1,asign + rts pc +1: + mov $1,asign + rts pc + diff --git a/fpterp/fpx.s b/fpterp/fpx.s new file mode 100644 index 0000000000..c23cb6bb24 --- /dev/null +++ b/fpterp/fpx.s @@ -0,0 +1,36 @@ +/ fpx -- floating point simulation +.globl _reenter + +.data +_reenter: 1 + +.bss +bins: .=.+30 +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/lib/READ_ME b/lib/READ_ME new file mode 100644 index 0000000000..c35e8f2ff6 --- /dev/null +++ b/lib/READ_ME @@ -0,0 +1 @@ +The routines in libX.a are from ../s7 and are used by ex and ashell. diff --git a/man1/cd.1 b/man1/cd.1 new file mode 100644 index 0000000000..d0ccbb21f4 --- /dev/null +++ b/man1/cd.1 @@ -0,0 +1,25 @@ +.th CD I 10/15/76 +.sh NAME +cd \*- change working directory +.sh SYNOPSIS +.bd cd +directory +.sh DESCRIPTION +.it Directory +becomes the new working directory. +The process must have execute (search) +permission in +.it directory. +.s3 +Because a new process is created to execute each command, +.it cd +would be ineffective if it were written as a +normal command. It is therefore recognized and executed +by the Shell. +.it Cd +is exactly equivalent to +.it chdir +(I). +.sh "SEE ALSO" +sh (I), pwd (I), chdir (I) +.sh BUGS diff --git a/man1/lib.1 b/man1/lib.1 new file mode 100644 index 0000000000..786a2ffb69 --- /dev/null +++ b/man1/lib.1 @@ -0,0 +1,45 @@ +.th LIB I 10/14/76 +.sh NAME +lib \*- specify user libraries +.sh SYNOPSIS +.bd lib +directory ... +.sh DESCRIPTION +.it Lib +is used to specify user libraries to be searched by the shell. +The libraries are searched after the current directory and before +the system libraries `/bin' and `/usr/bin'. +.it Lib +with no arguments prints the current library. To specify no +libraries do: +.s2 +.ti 10 +lib "" +.br +.s3 +.it Lib +is executed within the Shell. +.sh "SEE ALSO" +sh (I), glob2 (VIII) +.sh BUGS +Other than the shell and +.it glob2 +(VIII) +which receives the library names explicitly, +there is no access to the current library names for user or other system +commands. +Thus +.it time +(I), +.it nice +(I), +.it nohup +(I), +.it if +(I), +.it find +(I), +and +.it repeat +(VI) +among others don't act as one would first expect. diff --git a/man1/login.1 b/man1/login.1 new file mode 100644 index 0000000000..1b71870985 --- /dev/null +++ b/man1/login.1 @@ -0,0 +1,60 @@ +.th LOGIN I 3/15/72 +.sh NAME +login \*- sign onto UNIX +.sh SYNOPSIS +.bd login +[ username ] +.sh DESCRIPTION +The +.it login +command +is used when a user initially +signs onto UNIX, or it may be used at any time to change +from one user to another. +The latter case is the one summarized above and +described here. +See `How to Get Started' for how to dial up initially. +.s3 +If +.it login +is invoked without an argument, +it asks for a user name, and, if +appropriate, a password. +Echoing is turned off (if possible) during the typing of the password, +so it will not appear on the written record of the +session. +.s3 +After a successful login, +accounting files are updated and +the user is informed of the +existence of +.it /usr/mail/username +and message-of-the-day files. +.it Login +initializes the user and group IDs and the working directory, +then executes a command interpreter (usually +.it sh +(I)) according to specifications found in a password file. +.s3 +Login is recognized by the Shell +and executed directly (without forking). +.sh FILES +/etc/utmp accounting +.br +/usr/adm/wtmp accounting +.br +.li +/usr/mail/username mail +.br +/etc/motd message-of-the-day +.br +/etc/passwd password file +.sh "SEE ALSO" +init (VIII), getty (VIII), mail (I), passwd (I), passwd (V) +.sh DIAGNOSTICS +`login incorrect,' +if the name or the password is bad. +`No Shell,', `cannot open password file,' `no directory': +consult a UNIX programming counselor. +.sh BUGS +Login is currently disabled at UCB. diff --git a/man1/sh.1 b/man1/sh.1 new file mode 100644 index 0000000000..a4d8cccdd6 --- /dev/null +++ b/man1/sh.1 @@ -0,0 +1,363 @@ +.th SH I 10/28/76 +.sh NAME +sh \*- shell (command interpreter) +.sh SYNOPSIS +.bd sh +[ +.bd \*-tciv +] +[ name [ arg1 ... [ arg9 ... ] ] ] +.sh DESCRIPTION +.it Sh +is the standard command interpreter. +It is the program which reads and arranges the execution of +the command lines typed by most users. +It may itself be called as a command to interpret +files of commands. +Before discussing the arguments to the Shell +used as a command, the structure of command +lines themselves will be given. +.s3 +.bd "Commands." +Each command is a sequence of non-blank command arguments +separated by blanks. +The +first argument specifies the name of a command to be +executed. +Except for certain types of special +arguments discussed below, the arguments +other than the command name are passed +without interpretation to the invoked +command. +.s3 +If the first argument is the name of an executable +file, it is invoked; +If the first argument is not the name of an executable file, +and it does not contain the character `/', the shell will search +other directories for the command. First it tries each user-specified library +(see lib (I)). If it still has not found the command, +tries the standard system library `/bin'. +(In this way most of the standard UNIX commands, +which reside in `/bin', are found.) +If this fails, it finally tries +the library `/usr/bin', +where lesser-used UNIX commands live. +.s3 +If a non-directory file has executable mode, +but not the form of an executable program +(does not begin with the proper magic number) +then it is examined to see if it is a Pascal object +(first word 0404 - a magic number). If it is, then +a new pascal interpreter is created to interpret it. +Otherwise, it is assumed to be an ASCII file of commands +and a new Shell is created to execute it. +See ``Argument passing'' below. +.s3 +If the file cannot be found, +a diagnostic is printed. +.s3 +.bd "Command lines." +One or more commands separated by `|' or `^' constitute a +chain of +.it filters. +The standard output of each command but the last +is taken +as the standard input of the next command. +Each command is run as a separate process, connected +by pipes (see pipe(II)) to its neighbors. +A command line contained in +parentheses `( )' may appear in place of a simple command +as a filter. +.s3 +A +.it "command line" +consists of one or +more pipelines separated, and perhaps terminated by `\fB;\fR' or `&'. +The semicolon designates sequential execution. +The `&' causes the preceding command line to be executed +without waiting for it to finish. +The process id of such a command line is reported, so that +it may be used if necessary for a subsequent +.it wait +or +.it kill. +If, however, the `&' is followed by a `*', i.e. `&*', then +the preceding set of `;' separated commands is +put in the background, as a group. Thus `cc sh.c ; mv a.out sh &*' is equivalent +to `(cc sh.c ; mv a.out sh)&'. +.s3 +.bd "Termination Reporting." +If a command (not followed by `&') terminates abnormally, +a message is printed. +(All terminations other than exit and interrupt +are considered abnormal.) +Termination reports for commands followed by `&' +are given upon receipt of the first +command subsequent to the termination of +the command, +or when a +.it wait +is executed. +The following is a list of the abnormal +termination messages: +.s3 +.nf + Bus error + Trace/BPT trap + Illegal instruction + IOT trap + EMT trap + Bad system call + Quit + Floating exception + Memory fault + Killed +.s3 +.fi +If a core image is produced, +`\*- Core dumped' is appended to the appropriate message. +.s3 +.bd "Redirection of I/O." +There are three character sequences that cause the immediately following string +to be interpreted as a special argument to the Shell itself. +Such an argument may +appear anywhere among +the arguments of a simple command, or before or after +a parenthesized command list, and is associated with that +command or command list. +.s3 +An argument of the form `file' causes file `file' to be used +as the standard output (file descriptor 1) for the associated command. +`File' is created if it did not exist, and in any case is truncated +at the outset. +.s3 +An argument of the form `>>file' causes file `file' to be used as the +standard output for the associated command. +If `file' +did not exist, it is created; if it did exist, +the command output is appended to the file. +.s3 +For example, either of the command lines +.s3 + ls >junk; cat tail >>junk +.br + ( ls; cat tail ) >junk +.s3 +creates, on file `junk', a listing of the working directory, followed immediately +by the contents of file `tail'. +.s3 +Either of the constructs `>file' or `>>file' +associated with any but the last command of a pipeline +is ineffectual, as is `* file', +`>>* file', and `|* ...' cause both units 1 and 2 to refer +to the specified file or put through the pipe. +.s3 +.bd "Generation of argument lists." +If any argument contains any of the characters `?', +`*' or `[', it is treated specially as follows. +The current directory is searched for files which +.it match +the given argument. +.s3 +The character `*' in an argument matches any string of characters +in a file name (including the null string). +.s3 +The character `?' matches any +single character in a file name. +.s3 +Square brackets `[...]' specify +a class of characters which +matches any single file-name character in the class. +Within the brackets, +each ordinary character is taken +to be a member of the class. +A pair of characters separated by `\*-' places +in the class +each character lexically greater than or equal to +the first and less than or equal to the second +member of the pair. +.s3 +Other characters match only the same character in +the file name. +.s3 +For example, `*' matches all file names; +`?' matches all one-character file names; `[ab]*.s' matches +all file names beginning with `a' or `b' and ending with `.s'; +`?[zi\*-m]' matches all two-character file names ending +with `z' or the letters `i' through `m'. +.s3 +If the argument with `*', `?', or `[' also contains a `/', a slightly +different procedure is used: instead of the current directory, +the directory used is the one obtained +by taking the argument up to the last `/' before a `*' or `?'. +If a `/' appears thereafter, then the intervening string is matched +against the subdirectories of the derived directory. If there is no +following `/', +the matching process matches the remainder of the argument +after this `/' against the files in the derived directory. +For example: `/usr/dmr/a*.s' matches +all files in directory `/usr/dmr' which begin +with `a' and end with `.s'; +`/mnt*/*/.q' matches e.g. `/mnt/ken/.q' and `/mnt/chuck/.q' among +others. +.s3 +In any event, a list of names is obtained which match +the argument. +This list is sorted into alphabetical order, +and the resulting sequence of arguments replaces the +single argument containing the `*', `[', or `?'. +The same process is carried out for each argument +(the resulting lists are +.it not +merged) +and finally the command is called with the resulting list of +arguments. +.s3 +.bd "Quoting." +The character `\\' causes the immediately following character +to lose any special meaning it may have to the Shell; in this +way `<', `>', and other characters meaningful to the +Shell may be passed as part of arguments. +A special case of this feature allows the continuation of commands +onto more than one line: a new-line preceded by `\\' is translated +into a blank. +.s3 +Sequences of characters enclosed in double (") or single (\*a) +quotes are also taken literally. +For example: +.s3 + ls | pr \*-h "My directory" +.s3 +causes a directory listing to be produced +by +.it ls, +and passed on to +.it pr +to be +printed with the heading `My directory'. +Quotes permit the inclusion of blanks in +the heading, which is a single argument to +.it pr. +.s3 +.bd "Argument passing." +When the Shell is invoked as a command, it has additional +string processing capabilities. +Recall that the form in which the Shell is invoked is +.s3 + sh [ name [ arg1 ... [ arg9 ... ] ] ] +.s3 +The +.it name +is the name of a file which is read and +interpreted. +If not given, this subinstance of the Shell +continues to read the standard input file. +.s3 +In command lines in the file +(not in command input), +character sequences of the form `$n', where +.it n +is a digit, +are replaced by the +\fIn\fRth argument to the invocation +of the Shell (argn). +`$0' is replaced by +.it name. +Finally `$*' is replaced by the remaining arguments +starting with `$1'. +.s3 +The argument `\*-t,' causes +.it sh +to read the standard input for a single line, execute +it as a command, and then exit. +This facility replaces the older `mini-shell.' +It is useful for interactive programs +which allow users to execute +system commands. +.s3 +The argument `\*-c' (used with one following argument) +causes the next argument to be taken as a command +line and executed. +No new-line need be present, but new-line characters +are treated appropriately. +This facility is useful as an alternative to +`-t' where the caller has already read +some of the characters of the command to be executed. +.s3 +The argument `\*-i' causes the shell to be `interactive', +that is, the shell ignores interrupts and quits. +Login shells are interactive, as are +all shells whose input and output are both ttys. +Interactive shells also have interruptible waits (see wait(I)). +.s2 +The argument `-v' causes the shell to echo each command line, with +a prompt, as it is printed. +.s3 +.bd "End of file." +An end-of-file in the Shell's input causes it to exit. +A side effect of this fact means that the way to +log out from UNIX is to type an EOT. +.s3 +.bd "Special commands." +The following commands are treated specially by the Shell. +.s3 +.it chdir +is done without +spawning a new process by executing +.it "sys chdir" +(II). +"cd" is a useful abbreviation for "chdir". +.s3 +.it login +is done by executing +/bin/login without creating a new process. +.s3 +.it wait +is done without spawning a new process by +executing +.it "sys wait" +(II). +.s3 +.it shift +is done by manipulating the arguments +to the Shell. +.s3 +.it lib +is done by manipulating internal data. +.s3 +`\fB:\fR' is simply ignored. +.s3 +.bd "Command file errors; interrupts." +Any Shell-detected error, or an interrupt signal, +during the execution of a command file +causes the Shell to cease execution of that file. +.s3 +Processes that are created with `&' ignore interrupts. +Also if such a process has not redirected its +input with a `<', +its input is automatically redirected to the +zero length file /dev/null. +.sh FILES +/etc/glob2, +which interprets `*', `?', and `['. +.br +/dev/null as a source of end-of-file. +.br +/bin/px the Pascal interpreter. +.sh "SEE ALSO" +`The UNIX Time-Sharing System', +CACM, July, 1974. +.s2 +chdir (I), login (I), wait (I), shift (I), glob (VIII), cd (I), lib (I) diff --git a/man1/su.8 b/man1/su.8 new file mode 100644 index 0000000000..00e3e10dd1 --- /dev/null +++ b/man1/su.8 @@ -0,0 +1,24 @@ +.th SU VIII 10/31/73 +.sh NAME +su \*- become privileged user +.sh SYNOPSIS +.bd su +.sh DESCRIPTION +.it Su +allows one to become the super-user, who has +all sorts of marvelous (and correspondingly dangerous) powers. +In order for \fIsu\fR to do its magic, the user must +supply a password. +If the password is correct, \fIsu\fR +will execute the Shell with the UID set to +that of the super-user. +To restore normal UID privileges, +type an end-of-file to the super-user Shell. +.s3 +The password demanded is that of the entry ``root'' +in the system's password file. +.s3 +To remind the super-user of his responsibilities, +the Shell substitutes `#' for its usual prompt `%'. +.sh "SEE ALSO" +sh (I) diff --git a/man1/wait.1 b/man1/wait.1 new file mode 100644 index 0000000000..31bc7f7f01 --- /dev/null +++ b/man1/wait.1 @@ -0,0 +1,32 @@ +.th WAIT I 4/9/73 +.sh NAME +wait \*- await completion of process +.sh SYNOPSIS +.bd wait +.sh DESCRIPTION +Wait until all processes started with +.bd `&' +have completed, +and report on abnormal terminations. +.s3 +Because +.it "sys wait" +must be executed in the parent process, +the Shell itself executes +.it wait, +without creating a new process. +.sh "SEE ALSO" +sh (I) +.sh BUGS +After executing +.it wait +in a non-interactive shell +you are committed to waiting until +termination, +because interrupts and quits are ignored +by all processes concerned. +The only out, if the process does not terminate, +is to +.it kill +it from another terminal or to +hang up. diff --git a/man8/glob2.8 b/man8/glob2.8 new file mode 100644 index 0000000000..bee1a5db96 --- /dev/null +++ b/man8/glob2.8 @@ -0,0 +1,23 @@ +.th GLOB2 VIII 10/15/76 +.sh NAME +glob2 \*- generate command arguments +.sh SYNOPSIS +.bd /etc/glob2 +libs command [ arguments ] +.sh DESCRIPTION +.it Glob2 +is used to expand arguments to the shell containing ``*'', ``['', or +``?''. +It is passed the argument list +containing the metacharacters; +.it glob2 +expands the list and calls the indicated command. +The libs argument is a string containing all the current user library +names separated by blanks. +The actions of +.it glob2 +are detailed in +the Shell writeup. +.sh SEE ALSO" +sh (I), lib (I) +.sh BUGS diff --git a/man8/quotfix.8 b/man8/quotfix.8 new file mode 100644 index 0000000000..7c7a9707a5 --- /dev/null +++ b/man8/quotfix.8 @@ -0,0 +1,63 @@ +.th QUOTFIX VIII 8/28/77 +.sh NAME +quotfix \- correct block quota files on a subtree +.sh SYNOPSIS +.bd quotfix +[ +.bd \- +] [ +.bd \-a +] [ +.bd \-n +] [ +dirname ... +] +.sh DESCRIPTION +.it Quotfix +recursively descends the directory structure +starting at each named directory +and corrects any block quota files which deviate from +the correct quota. +The current directory is the default if no directories are specified. +Use of quotfix requires super-user privileges. +.s3 +By default, +.it quotfix +lists subdirectories which had incorrect quotas +and those which have exceeded their quota. +Directories with incorrect quotas are +represented on a line with an `e' in the first column, those with +the quota exceeded have a `>' in column 2. +.s3 +The \fB\-\fR option suppresses all output. +.s3 +The \fB\-n\fR option causes no corrections to be made. The function is that +of a `check'. +.s3 +The \fB\-a\fR option causes +.it quotfix +to break the summary down +with a listing for each quota file encountered. +The result is an indented +representation of the file system usage for the subtree +rooted at the specified directory. +.sh SEE\ ALSO +quot (I), du (I) +.sh BUGS +If there is any activity in the subtree while the +program is running, the result is likely to be incorrect. +.s3 +.it Quotfix's +algorithm for setting quota's charges for each directory entry regardless +of the presence of multiple links. +The quota it determines agrees with the +result of +.it du +(I) +only in the absence of links. +In certain cases this makes +.it quotfix +almost useless; +.it quotfix +should be changed to work like +.it du. diff --git a/pcs/READ_ME b/pcs/READ_ME new file mode 100644 index 0000000000..6f70202b90 --- /dev/null +++ b/pcs/READ_ME @@ -0,0 +1,11 @@ +November 13, 1977 + +This directory contains the source for the Pascal program pascals. +It should be put in /usr/lib/pascals, the C program in in ../s6/pascals.c +should be put in /usr/bin/pascals... this C driver hunts up "px" +and executes the /usr/lib/pascals. + +For this program to run at any sort of reasonable speed it should be +compiled with the options "-p" and "-t" and preferably "-b", i.e.: + + pi -pbt pascals.p diff --git a/pcs/installpcs b/pcs/installpcs new file mode 100644 index 0000000000..7903c3f0d4 --- /dev/null +++ b/pcs/installpcs @@ -0,0 +1,5 @@ +cd ../s6 +cc -n -O pascals.c -o /usr/bin/pascals -s +cd ../pcs +pi -pbt pascals.p +mv obj /usr/lib/pascals diff --git a/pcs/scanner.i b/pcs/scanner.i new file mode 100644 index 0000000000..6876a2763e --- /dev/null +++ b/pcs/scanner.i @@ -0,0 +1,148 @@ +procedure nextch; (*read next character; process line end*) +begin if cc = ll then + begin if eof(input) then + begin writeln; + writeln(' program incomplete'); + errormsg; goto 99 + end ; + if errpos <> 0 then + begin writeln; errpos := 0 + end ; + write(lc:6, ' '); + ll := 0; cc := 0; + while not eoln(input) do + begin ll := ll+1; read(ch); write(ch); line[ll] := ch + end ; + writeln; ll := ll+1; read(line[ll]) + end ; + cc := cc+1; ch := line[cc]; +end (*nextch*) ; + +procedure insymbol; (*reads next symbol*) + label 1,2,3; + var i,j,k,e: integer; + + procedure readscale; + var s, sign: integer; + begin nextch; sign := 1; s := 0; + if ch = '+' then nextch else + if ch = '-' then begin nextch; sign := -1 end ; + while ch in ['0'..'9'] do + begin s := 10*s + ord(ch) - ord('0'); nextch + end ; + e := s*sign + e + end (*readscale*) ; + + procedure adjustscale; + var s: integer; d,t: real; + begin if k+e > emax then error(21) else + if k+e < emin then rnum := 0 else + begin s := abs(e); t := 1.0; d := 10.0; + repeat + while not odd(s) do + begin s := s div 2; d := sqr(d) + end ; + s := s-1; t := d*t + until s = 0; + if e >= 0 then rnum := rnum*t else rnum := rnum/t + end + end (*adjustscale*) ; + +begin (*insymbol*) +1: while (ch = ' ') or (ch = TAB) do nextch; + if ch in ['a'..'z'] then + begin (*identifier or wordsymbol*) k := 0; id := ' '; + repeat if k < alng then + begin k := k+1; id[k] := ch + end ; + nextch + until not (ch in ['a'..'z','0'..'9']); + i := 1; j := nkw; (*binary search*) + repeat k := (i+j) div 2; + if id <= key[k] then j := k-1; + if id >= key[k] then i := k+1 + until i > j; + if i-1 > j then sy := ksy[k] else sy := ident + end else + if ch in ['0'..'9'] then + begin (*number*) k := 0; inum := 0; sy := intcon; + repeat inum := inum*10 + ord(ch) - ord('0'); + k := k+1; nextch + until not (ch in ['0'..'9']); + if (k > kmax) or (inum > nmax) then + begin error(21); inum := 0; k := 0 + end ; + if ch = '.' then + begin nextch; + if ch = '.' then ch := ':' else + begin sy := realcon; rnum := inum; e := 0; + while ch in ['0'..'9'] do + begin e := e-1; + rnum := 10.0*rnum + (ord(ch)-ord('0')); nextch + end ; + if ch = 'e' then readscale; + if e <> 0 then adjustscale + end + end else + if ch = 'e' then + begin sy := realcon; rnum := inum; e := 0; + readscale; if e <> 0 then adjustscale + end ; + end else + case ch of +':' : begin nextch; + if ch = '=' then + begin sy := becomes; nextch + end else sy := colon + end ; +'<' : begin nextch; + if ch = '=' then begin sy := leq; nextch end else + if ch = '>' then begin sy := neq; nextch end else sy := lss + end ; +'>' : begin nextch; + if ch = '=' then begin sy := geq; nextch end else sy := gtr + end ; +'.' : begin nextch; + if ch = '.' then + begin sy := colon; nextch + end else sy := period + end ; +'''': begin k := 0; + 2: nextch; + if ch = '''' then + begin nextch; if ch <> '''' then goto 3 + end ; + if sx+k = smax then fatal(7); + stab[sx+k] := ch; k := k+1; + if cc = 1 then + begin (*end of line*) k := 0; + end + else goto 2; + 3: if k = 1 then + begin sy := charcon; inum := ord(stab[sx]) + end else + if k = 0 then + begin error(38); sy := charcon; inum := 0 + end else + begin sy := string; inum := sx; sleng := k; sx := sx+k + end + end ; +'(' : begin nextch; + if ch <> '*' then sy := lparent else + begin (*comment*) nextch; + repeat + while ch <> '*' do nextch; + nextch + until ch = ')'; + nextch; goto 1 + end + end ; +'+', '-', '*', '/', ')', '=', ',', '[', ']', '#', '&', ';' : + begin sy := sps[ch]; nextch + end ; +'$', '\', '!', '?', '@', '_', '"', '^' : + begin error(24); nextch; goto 1 + end + end; +end (*insymbol*) ; + diff --git a/pcs/tables.i b/pcs/tables.i new file mode 100644 index 0000000000..95a05dd715 --- /dev/null +++ b/pcs/tables.i @@ -0,0 +1,88 @@ +procedure enter(x0: alfa; x1: object; + x2: types; x3: integer); +begin t := t+1; (*enter standard identifier*) + with tab[t] do + begin name := x0; link := t-1; obj := x1; + typ := x2; ref := 0; normal := true; + lev := 0; adr := x3 + end +end (*enter*) ; + +procedure enterarray(tp: types; l,h: integer); +begin if l > h then error(27); + if (abs(l)>xmax) or (abs(h)>xmax) then + begin error(27); l := 0; h := 0; + end ; + if a = amax then fatal(4) else + begin a := a+1; + with atab[a] do + begin inxtyp := tp; low := l; high := h + end + end +end (*enterarray*) ; + +procedure enterblock; +begin if b = bmax then fatal(2) else + begin b := b+1; btab[b].last := 0; btab[b].lastpar := 0 + end +end (*enterblock*) ; + +procedure enterreal(x: real); +begin if c2 = c2max-1 then fatal(3) else + begin rconst[c2+1] := x; c1 := 1; + while rconst[c1] <> x do c1 := c1+1; + if c1 > c2 then c2 := c1 + end +end (*enterreal*) ; + +procedure emit(fct: integer); +begin if lc = cmax then fatal(6); + code[lc].f := fct; lc := lc+1 +end (*emit*) ; + +procedure emit1(fct,b: integer); +begin if lc = cmax then fatal(6); + with code[lc] do + begin f := fct; y := b end ; + lc := lc+1 +end (*emit1*) ; + +procedure emit2(fct,a,b: integer); +begin if lc = cmax then fatal(6); + with code[lc] do + begin f := fct; x := a; y := b end ; + lc := lc+1 +end (*emit2*) ; + +procedure printtables; + var i: integer; o: order; +begin + writeln('0identifiers link obj typ ref nrm lev adr'); + for i := btab[1].last +1 to t do + with tab[i] do + writeln(i,' ',name,link:5, ord(obj):5, ord(typ):5, ref:5, + ord(normal):5, lev:5, adr:5); + writeln('0blocks last lpar psze vsze'); + for i := 1 to b do + with btab[i] do + writeln(i, last:5, lastpar:5, psize:5, vsize:5); + writeln('0arrays xtyp etyp eref low high elsz size'); + for i := 1 to a do + with atab[i] do + writeln(i, ord(inxtyp):5, ord(eltyp):5, + elref:5, low:5, high:5, elsize:5, size:5); + writeln('0code:'); + for i := 0 to lc-1 do + begin if i mod 5 = 0 then + begin writeln; write(i:5) + end ; + o := code[i]; write(o.f:5); + if o.f < 31 then + if o.f < 4 then write(o.x:2, o.y:5) + else write(o.y:7) + else write(' '); + write(',') + end ; + writeln +end (*printtables*) ; + diff --git a/s1/READ_ME b/s1/READ_ME new file mode 100644 index 0000000000..22c065030f --- /dev/null +++ b/s1/READ_ME @@ -0,0 +1,20 @@ +Here are a passwd command which asks you for the password twice so +you dont screw yourself up, and a shell which has a couple nice features +(interruptible waits, redirect unit 2) and which knows about Pascal +objects... the glob (../s8/glob2.c) which goes with this shell +takes arbitrary path names, i.e. + /*/mbox + +This shell has been the standard at Berkeley for over a year. + +The login and su in ../s8 maintain the htmp data base, and also +implement ".start_up" files which a shell runs when you log in. +Also implemented are the file ".reminder" which you can place +in your login directory to have catted on your terminal when you +log in. + +These features of login are superfluous if you have "../ashell" +but very useful otherwise. The "su" program also maintains an +unused byte in /etc/utmp so that the "who" here can print out +who you are "su'd" to ... currently we disable su's to anyone but +the root except by the root ... this is easy to take out. diff --git a/s1/passwd.c b/s1/passwd.c new file mode 100644 index 0000000000..18c5e44369 --- /dev/null +++ b/s1/passwd.c @@ -0,0 +1,219 @@ +/* + * enter a password in the password file + * this program should be suid with owner + * with an owner with write permission on /etc/passwd + */ +char *tfile { "/usr/adm/ptmp" }; +char *pfile { "/etc/passwd" }; +char *pw; +char pwbuf[10]; +int ttybuf[3]; +int tbuf[259]; +int pbuf[259]; + +main(argc, argv) +char *argv[]; +{ + register u, c; + register char *p; + int exitt(); + int v; + char x; + + if(argc < 2) { + write(2, "Usage: passwd user [ password ]\n", 32); + goto bex; + } + if(argc == 2) { + signal(1, &exitt); + signal(2, &exitt); + signal(3, &exitt); + gtty(0, ttybuf); + ttybuf[2] =& ~010; + stty(0, ttybuf); +again: + write(2, "Password: ", 10); + p = pwbuf; + for(;;) { + if(read(0, p, 1) != 1) + break; + if(*p == '\n') + break; + if(p < pwbuf+9) + p++; + } + *p = 0; + write(2, "\nAgain: ", 8); + p = pwbuf; + for (;;) { + if (read(0, &x, 1) != 1 || x == '\n') + break; + if (*p++ != x) { +xxx: + while (read(0, &x, 1) == 1 && x != '\n') + continue; + write(2, "\nThose weren't the same\n", 24); + goto again; + } + } + if (*p != 0) + goto xxx; + ttybuf[2] =| 010; + stty(0, ttybuf); + write(2, "\n", 1); + pw = pwbuf; + } else + pw = argv[2]; + signal(1, 1); + signal(2, 1); + signal(3, 1); + + if(stat(tfile, tbuf+20) >= 0) { + write(2, "Temporary file busy -- try again\n", 33); + goto bex; + } + tbuf[0] = creat(tfile, 0600); + if(tbuf[0] < 0) { + write(2, "Cannot create temporary file\n", 29); + goto bex; + } + pbuf[0] = open(pfile, 0); + if(pbuf[0] < 0) { + write(2, "Cannot open /etc/passwd\n", 25); + goto out; + } + goto l1; + +/* + * skip to beginning of next line + */ + +skip: + while(c != '\n') { + if(c < 0) + goto ill; + c = getc(pbuf); + putc(c, tbuf); + } + +/* + * compare user names + */ + +l1: + c = getc(pbuf); + putc(c, tbuf); + if(c < 0) { + write(2, "User name not found in password file\n", 37); + goto out; + } + p = argv[1]; + while(c != ':') { + if(*p++ != c) + goto skip; + c = getc(pbuf); + putc(c, tbuf); + } + if(*p) + goto skip; +/* + * skip old password + */ + do { + c = getc(pbuf); + if(c < 0) + goto ill; + } while(c != ':'); + +/* + * copy in new password + */ + p = pw; + for(c=0; c<9; c++) + if(*p++ == 0) + break; + *--p = 0; + if(p != pw) + p = crypt(pw); + while(*p) + putc(*p++, tbuf); + putc(':', tbuf); + +/* + * validate uid and gid + */ + + u = 0; + do { + c = getc(pbuf); + putc(c, tbuf); + if(c >= '0' && c <= '9') + u = u*10 + c-'0'; + if(c < 0) + goto ill; + } while(c != ':'); + v = 0; + do { + c = getc(pbuf); + putc(c, tbuf); + if(c >= '0' && c <= '9') + v = v*10 + c-'0'; + if(c < 0) + goto ill; + } while(c != ':'); + c = getuid(); + if(c == 0) + goto ok; + if(c == ((v<<8) | u)) + goto ok; + if((c&0377) == 0 && ((c>>8)&0377) == v) + goto ok; + write(2, "Permission denied\n", 18); + goto out; +ok: + +/* + * copy out and back + */ + + for(;;) { + c = getc(pbuf); + if(c < 0) { + fflush(tbuf); + close(pbuf[0]); + close(tbuf[0]); + tbuf[0] = open(tfile, 0); + if(tbuf[0] < 0) { + write(2, "Urk\n", 4); + goto out; + } + pbuf[0] = creat(pfile, 0644); + if(pbuf[0] < 0) { + write(2, "Cannot create /etc/passwd\n", 27); + goto out; + } + while((c = read(tbuf[0], tbuf+1, 512)) > 0) + write(pbuf[0], tbuf+1, c); + unlink(tfile); + exit(0); + } + putc(c, tbuf); + } + +ill: + write(2, "Password file illformed\n", 24); + +out: + unlink(tfile); + +bex: + exit(1); +} + +exitt() +{ + ttybuf[2] =| 010; + stty(0, ttybuf); + write(2, "\n", 1); + exit(1); +} diff --git a/s1/sh.c b/s1/sh.c new file mode 100644 index 0000000000..12b994bb9a --- /dev/null +++ b/s1/sh.c @@ -0,0 +1,1069 @@ +# +/* + * UC berkeley shell + * + * Modified by Bill Joy Oct 14, 1976 + * + * library "lib" + * cd for "chdir" + * interruptible waits + * new accounting scheme + * interactive (login shell) option "-i" + * shells with input and output tty's ignore interrupts + * verbose option "-v" causes input commands to be echoed + * $* for all arguments $1 to end + * >* >>* and |* to put unit 2 there also + * `cmd1 ; ... ; cmdn &*' means `( cmd1 ; ... ; cmdn ) &' + * pascal objects are recognized and px's are forked + * gimme and normal + * working directory not searched for root + */ + +char shell[] "/bin/sh"; +char glob[] "/etc/glob2"; +char px[] "/bin/px"; + +#define PCXN 0404 +#define INTR 2 +#define QUIT 3 + +#define LINSIZ 1000 +#define ARGSIZ 50 +#define TRESIZ 100 +#define LIBSIZ 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 FDIAG 128 + +#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 ENOEXEC 8 +#define ENOMEM 12 + +int niceness; +char *dolp; +int *dolnxt; +char pidp[7]; +int dolc; +char **dolv; +char *promp "% "; +char *linep; +char **argp; +int *treep; +char peekc; +char gflg; +char nofile; +char error; +char acctf; +char *accpt; +char *accbuf; +int acct; +char acnm[] "/usr/adm/sha\0\0\0"; +char ty; +char tyed; +char echo; +int uid; +char setintr; +char *arginp; +char onelflg; + +char *mesg[] { + 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", + "Sig 15", + "Sig 16", +}; + +char line[LINSIZ]; +char *args[ARGSIZ]; +int trebuf[TRESIZ]; +char *lib; +char *numpt &pidp[sizeof pidp - 1]; + +main(c, av) +int c; +char **av; +{ + register f; + register char **v, *cp; + + for(f=3; f<15; f++) + close(f); + numb(numb(getpid())); + if ((uid = getuid()) == 0) + promp[0] = '#'; + v = av; + dolnxt = &v[c]; + if (c > 1) { + if (*(cp = v[1]) == '-') { + do + switch(*cp++) { + case 'v': + echo++; + break; + case 'c': + if (c > 2) + arginp = v[2]; + goto l1; + case 't': + onelflg = 2; + case '\0': + +l1: + *promp = '\0'; + case 'i': + **v = '-'; + nofile++; + break; + } + while (*cp); + v++; + c--; + } + if (nofile == 0 && c > 1) { + close(0); + if (open(cp = v[1], 0) < 0) { + prs(v[1]); + err(": cannot open"); + } + *promp = '\0'; + } + } + if ((ty = ttyn(0)) != 'x' && ttyn(1) != 'x') + **v = '-'; + if (**av == '-') { + setintr++; + signal(QUIT, 1); + signal(INTR, 1); + } + dolv = v+1; + dolc = c-1; + numpt = &acnm[sizeof acnm - 1]; + numb((uid>>8) & 0377); + numb(uid & 0377); + if ((acctf = open(acnm, 1)) >= 0 || echo) + accbuf = sbrk(256); + setexit(); + + for(;;) { + prs(promp); + if ((cp = accbuf) != 0) { + *cp++ = ty; + tyed++; + *cp++ = ' '; + accpt = cp; + acct = 254; + } + peekc = getc(); + main1(); + } +} + +numb(a) +{ + register i, j; + + i = a; + j = 3; + do { + *--numpt = (i % 10) | '0'; + i =/ 10; + } while(--j); + return(i); +} + +acflush() +{ + register f, c; + register char *b; + + if ((b = accbuf) != 0) { + c = 256 - acct; + if ((f = acctf)>= 0) { + seek(f, 0, 2); + write(f, b, c); + } + if (echo) { + if (tyed) + b[0] = uid ? '%' : '#'; + seek(2, 0, 2); + write(2, b, c); + } + accpt = b; + acct = 256; + } +} + +main1() +{ + register char c, *cp; + register *t; + + argp = args; + linep = line; + error = 0; + gflg = 0; + do { + cp = linep; + word(); + } while(*cp != '\n'); + treep = trebuf; + if (gflg == 0) { + if (error == 0) + t = syntax(args, argp); + if (error != 0) + err("syntax error"); + else { + acflush(); + 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 '&': + *linep++ = c; + if ((c = getc()) == '*') + *linep++ = c; + else + peekc = c; + *linep++ = '\0'; + return; + + 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 > &trebuf[TRESIZ]) { + prs("Command line overflow\n"); + error++; + reset(); /* UGH */ + } + return(t); +} + +getc() +{ + register c; + + if (peekc) { + c = peekc; + peekc = 0; + return(c); + } + if (argp > &args[ARGSIZ-5]) { + argp =- 10; + while((c=getc()) != '\n'); + argp =+ 10; + err("Too many args"); + gflg++; + return(c); + } + if (linep > &line[LINSIZ-5]) { + linep =- 10; + while((c=getc()) != '\n'); + linep =+ 10; + err("Too many characters"); + gflg++; + return(c); + } + for(;;) { + if (dolp) { + if ((c = *dolp++) != '\0') + return(c); + dolp = *dolnxt; + c = dolp; + if (c != -1) { + dolnxt++; + return(' '); + } + dolp = 0; + } + if ((c = readc()) == '\\') + if ((c = readc()) == '\n') + return(' '); + else + return(c | QUOTE); + else if (c == '$') { + c = readc(); + if (c >= '0' && c <= '9') { + if (c - '0' < dolc) + dolp = dolv[c - '0']; + continue; + } + else if (c == '$') { + dolp = &pidp[1]; + continue; + } + else if (c == '*') { + if (dolc > 1) { + dolp = dolv[1]; + dolnxt = &dolv[2]; + } + continue; + } + } + return(c&0177); + } +} + +readc() +{ + char cc; + register c; + register char *cp; + + if (arginp) { + if (arginp == 1) + exit(0); + else if ((c = *arginp++) == '\0') { + arginp = 1; + c = '\n'; + } + } else if (onelflg == 1 || read(0, &cc, 1) != 1) + exit(0); + else if ((c = cc) == '\n' && onelflg) + onelflg--; + if ((cp = accpt) != 0) { + *cp++ = c; + if (--acct == 0) + acflush(); + else + accpt = cp; + } + return(c); +} + +/* + * syntax + * empty + * syn1 + */ + +syntax(p1, p2) +char **p1, **p2; +{ + + while(p1 != p2) { + if (any(**p1, ";&\n")) + p1++; + else + return(syn1(p1, p2, 1)); + } + return(0); +} + +/* + * syn1@fl=0 + * syn2 + * syn2 ; syntax + * syn2 & + * + * When fl=1 syn1 handles the vagarities of &* + */ + +syn1(p1, p2, fl) +char **p1, **p2; +{ + register char **p; + register *t, *t1; + int l; + +top: + l = 0; + for(p=p1; p!=p2; p++) + switch(**p) { + + case '(': + l++; + continue; + + case ')': + l--; + if (l < 0) + error++; /* too many ')'s */ + continue; + + case ';': + case '\n': + if (fl) + continue; + case '&': + if (l == 0) { + if (fl) { + l = (*p)[1]; + if (l == '*') + **p = ';'; + t1 = syn1(p1, p+1, 0); + if (l == '*') + if (t1[DTYP] == TLST) { + t = tree(5); + t[DTYP] = TPAR; + t[DLEF] = 0; + t[DRIT] = 0; + t[DFLG] = FAND|FPRS|FINT; + t[DSPR] = t1; + t1 = t; + } else { + t = t1[DLEF]; + t[DFLG] =| FAND|FPRS|FINT; + } + } else { + l = **p; + t1 = syn2(p1, p); + if (l == '&') + t1[DFLG] =| FAND|FPRS|FINT; + } + t = tree(4); + t[DTYP] = TLST; + t[DFLG] = 0; + t[DLEF] = t1; + t[DRIT] = syntax(p+1, p2); + return(t); + } + } + if (l == 0) + if (fl) { + fl = 0; + goto top; + } else + return(syn2(p1, p2)); + error++; +} + +/* + * 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); + p++; + if (p != p2 && **p == '*') { + t[DFLG] = FDIAG; + if ((*p)[1] != '\0') { + (*p)++; + p--; + } + } else { + t[DFLG] = 0; + p--; + } + t[DRIT] = syn2(p+1, p2); + return(t); + } + } + return(syn3(p1, p2)); +} + +/* + * syn3 + * ( syn1@1 ) [ < 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--; + p++; + if (p != p2 && **p == '*') { + flg =| FDIAG; + if ((*p)[1] != '\0') { + (*p)++; + p--; + } + } else + p--; + + case '<': + if (l == 0) { + p++; + if (p == p2) { + error++; + p--; + } + if (any(**p, "<>(")) + error++; + if (c == '<') { + if (i != 0) + error++; + i = *p; + } else { + 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, 1); + } else { + if (n == 0) + error++; + p1[n++] = 0; + t = tree(n+5); + t[DTYP] = TCOM; + for(l=0; l= 0) + seek(1, 0, 2); + else if (creat(cp2, 0644) < 0) { + prs(t1[DRIT]); + err(": cannot create"); + exit(1); + } + } + 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&FDIAG) { + close(2); + dup(1); + } + if ((f&FINT)!=0 && t1[DLEF]==0 && (f&FPIN)==0) { + close(0); + open("/dev/null", 0); + } + if ((f&FINT) == 0 && setintr) { + signal(INTR, 0); + signal(QUIT, 0); + } + if (t1[DTYP] == TPAR) { + if (t1 = t1[DSPR]) + t1[DFLG] =| f&FINT; + execute(t1); + exit(1); + } + close(acctf); + gflg = 0; + scan(t1+1, &tglob); + if (gflg) { + t1 = &t1[DSPR-1]; + *t1++ = glob; + if ((*t1 = lib) == 0) + *t1 = &""; + t1--; + execv(*t1, t1); + prs("glob: cannot execute\n"); + exit(1); + } + scan(t1, &trim); + cp1 = t1[DCOM]; + while(*cp1 && *cp1 != '/') + cp1++; + if (*cp1 || uid) + texec(t1[DCOM], t1); + if (!*cp1) { + if (cp2 = lib) + for(;;) { + while (*cp2 == ' ') + cp2++; + if (!*cp2) + break; + cp1 = linep; + while(*cp2) + if (*cp2 == ' ') + break; + else + *cp1++ = *cp2++; + scp = cp2; + *cp1++ = '/'; + cp2 = t[DCOM]; + while(*cp1++ = *cp2++) + continue; + texec(linep, t1); + cp2 = scp; + } + cp1 = linep; + cp2 = "/usr/bin/"; + while(*cp1 = *cp2++) + cp1++; + cp2 = t1[DCOM]; + while(*cp1++ = *cp2++); + texec(linep+4, t1); + texec(linep, t1); + } + prs(t1[DCOM]); + err(": not found"); + exit(1); + + case TFIL: + f = t[DFLG]; + pipe(pv); + t1 = t[DLEF]; + t1[DFLG] =| FPOU | (f&(FPIN|FINT|FPRS|FDIAG)); + 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, *t1; + register i; + int w; + + t = at; + execv(f, (t1 = &t[DCOM])); + if (errno == ENOEXEC) { + *t1 = f; + *--t1 = shell; + i = open(f, 0); + if (i >= 0) { + if (read(i, &w, 2) == 2 && w == PCXN) + *t1 = px; + close(i); + } + execv(*t1, t1); + prs("No "); + prs(*t1); + err("!!\n"); + exit(1); + } else if (errno==ENOMEM) { + prs(*t1); + err(": too large"); + exit(1); + } +} + +err(s) +char *s; +{ + + prs(s); + prs("\n"); + if (*promp == '\0') { + seek(0, 0, 2); + exit(); + } +} + +prs(as) +char *as; +{ + register char *s; + + if (s = as) { + while(*s) + s++; + write(2, as, s-as); + } +} + +prn(n) +int n; +{ + register a; + + if (a = n/10) + prn(a); + n = n % 10 + '0'; + write(2, &n, 1); +} + +getn(acp) +char *acp; +{ + register i; + register char c, *cp; + + cp = acp; + i = 0; + while ((c = *cp++) != '\0') + if (c >= '0' && c <= '9') + i = 10 * i + c - '0'; + return(i); +} + +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(ai) +int ai; +{ + register p, e, i; + int s; + + if ((i = ai) != 0) + do { + p = wait(&s); + if (p == -1) + break; + e = s & 0177; + if (mesg[e] != 0) { + if (p != i) { + prn(p); + prs(": "); + } + prs(mesg[e]); + if (s & 0200) + prs(" -- Core dumped"); + } + if (e != 0) + err(""); + } while (i != p); +} diff --git a/s1/who.c b/s1/who.c new file mode 100644 index 0000000000..39eaa75f45 --- /dev/null +++ b/s1/who.c @@ -0,0 +1,89 @@ +/* + * who + */ + +int fout; +int buf[256]; +char pbuf[100]; + +main(argc, argv) +char **argv; +{ + char *s, *cbuf; + int n, fi, i; + int tty; + struct { + char name[8]; + char tty; + char changed; + int time[2]; + int uid; + } *p; + + s = "/etc/utmp"; + if(argc == 2) + s = argv[1]; + fi = open(s, 0); + if(fi < 0) { + write("cannot open wtmp\n", 17); + exit(); + } + fout = dup(1); + close(1); + if (argc==3) + tty = ttyn(2); + +loop: + n = read(fi, buf, 512); + if(n == 0) { + flush(); + if (argc==3) + write(fout, "Nobody.\n", 8); + exit(); + } + + p = &buf; + for(p = &buf; (n =- 16)>=0; p++) { + if (argc==3 && tty!=p->tty) + continue; + if(p->name[0] == '\0' && argc==1) + continue; + for(i=0; i<8; i++) { + if (p->name[i]<' ' || p->name[i]>'z') + p->name[i] = ' '; + putchar(p->name[i]); + } + putchar(' '); + for(i=0; i<3; i++) + putchar("tty"[i]); + i = p->tty; + if (i < 033) { + putchar('^'); + putchar(i - 1 + 'a'); + } else { + putchar(i); + putchar(' '); + } + cbuf = ctime(p->time); + for(i=3; i<16; i++) + putchar(cbuf[i]); + if (p->changed && argc != 2) + { + if (getpw(p->uid, pbuf)) + goto out; + s = pbuf; + putchar(' '); + for(i=0; i < 8; i++) + if (*s == ':') + break; + else putchar(*s++); + } +out: + putchar('\n'); + if (argc==3) { + flush(); + exit(); + } + } + goto loop; +} diff --git a/tests/ancestor.p b/tests/ancestor.p new file mode 100644 index 0000000000..e6d5b7dff3 --- /dev/null +++ b/tests/ancestor.p @@ -0,0 +1,24 @@ +program ancestor(output); +{R.W.Floyd: 'Ancestor', Comm.ACM 6-62 and 3-63, Alg.96} + const n = 100; + var i,j,k: integer; + r: array [1..n, 1..n] of boolean; +begin { r[i,j] = "i is a parent of j"} + for i := 1 to n do + for j := 1 to n do r[i,j] := false; + for i := 1 to n do + if i mod 10 <> 0 then r[i,i+1] := true; + writeln(clock); + for i := 1 to n do + for j := 1 to n do + if r[j,i] then + for k := 1 to n do + if r[i,k] then r[j,k] := true; + writeln(clock); + for i := 1 to n do + begin write(' '); + for j := 1 to n do write(chr(ord(r[i,j])+ord('0'))); + writeln + end ; + writeln(clock) +end . diff --git a/tests/ancestor2.p b/tests/ancestor2.p new file mode 100644 index 0000000000..2f75e8dcf0 --- /dev/null +++ b/tests/ancestor2.p @@ -0,0 +1,22 @@ +program ancestor2(output); +{ancestor algorithm using sets instead of boolean matrix} + const n = 100; + var i,j: integer; + r: array [1..n] of set of 1..n; +begin { j in r[i] = "i is a parent of j"} + for i := 1 to n do + if i mod 10 <> 0 then r[i] := [i+1] else r[i] := []; + writeln(clock); + for i := 1 to n do + for j := 1 to n do + if i in r[j] then + r[j] := r[i]+r[j]; + writeln(clock); + for i := 1 to n do + begin write(' '); + for j := 1 to n do + if j in r[i] then write('1') else write('.'); + writeln + end ; + writeln(clock) +end . diff --git a/tests/cntchars.p b/tests/cntchars.p new file mode 100644 index 0000000000..5bb277a62e --- /dev/null +++ b/tests/cntchars.p @@ -0,0 +1,23 @@ +program countcharacters(input,output); + var ch: char; + c0,c1,c2,c3,c4: integer; {counters} +begin writeln(clock); { linelimit(output, -1); } + c0 := 0; c1 := 0; c2 := 0; c3 := 0; c4 := 0; + while not eof(input) do + begin write(' '); c0 := c0+1; + while not eoln(input) do + begin read(ch); write(ch); + if ch = ' ' then c1 := c1+1 else + if ch in ['a'..'z'] then c2 := c2+1 else + if ch in ['0'..'9'] then c3 := c3+1 else c4 := c4+1 + end ; + readln; writeln + end ; + writeln(clock); + writeln(c0,' lines'); + writeln(c1,' blanks'); + writeln(c2,' letters'); + writeln(c3,' digits'); + writeln(c4,' special characters'); + writeln(clock) +end . diff --git a/tests/eightqueens.p b/tests/eightqueens.p new file mode 100644 index 0000000000..6061cbbb51 --- /dev/null +++ b/tests/eightqueens.p @@ -0,0 +1,41 @@ +program eightqueens(output); +var i : integer; + a : array [ 1..8 ] of boolean; + b : array [ 2..16] of boolean; + c : array [-7..7 ] of boolean; + x : array [ 1..8 ] of integer; + safe : boolean; + + procedure print; + var k: integer; + begin write(' '); + for k := 1 to 8 do write(x[k]:2); + writeln + end ; + +procedure trycol(j : integer); + var i : integer; + + procedure setqueen; + begin a[i] := false; b[i+j] := false; c[i-j] := false; + end ; + + procedure removequeen; + begin a[i] := true; b[i+j] := true; c[i-j] := true; + end ; + + begin + repeat i := i+1; safe := a[i] and b[i+j] and c[i-j]; + if safe then + begin setqueen; x[j] := i; + if j < 8 then trycol(j+1) else print; + removequeen + end + until i = 8 +end; + +begin for i := 1 to 8 do a[i] := true; + for i := 2 to 16 do b[i] := true; + for i := -7 to 7 do c[i] := true; + writeln(clock); trycol(1); writeln(clock) +end. diff --git a/tests/insan.d b/tests/insan.d new file mode 100644 index 0000000000..de5e6dc219 --- /dev/null +++ b/tests/insan.d @@ -0,0 +1,5 @@ +wbggrb +wbrgrr +wbgwrg +wrgwbr + diff --git a/tests/insan.p b/tests/insan.p new file mode 100644 index 0000000000..7f1679d2d1 --- /dev/null +++ b/tests/insan.p @@ -0,0 +1,346 @@ +program insane(input, output); +label + 1; +type + alfa = packed array[1..10] of char; + face = (front, back, top, bottom, left, right); + pair = (one2, three4, five6); + color = (red, blue, green, white); + blockno = 1..4; +var + nosolutions: Boolean; + index, halfindex: integer; + pointr: integer; + data: array[blockno, face] of alfa; + sum: array[blockno, pair, color] of integer; + halfsolution: array[blockno, 1..30] of pair; + +function word(alf: alfa): color; +begin + if alf = 'red' then + word := red else + if alf = 'blue' then + word := blue else + if alf = 'green' then + word := green else + word := white; +end; + +procedure readin; +var + hue: alfa; + ch: char; + cube: blockno; + position: face; + +procedure tone; +begin + case ch of + 'r': hue := 'red'; + 'w': hue := 'white'; + 'g': hue := 'green'; + 'b': hue := 'blue'; + end; +end; + +begin + for cube := 1 to 4 do + begin + for position := front to right do + begin + read(ch); + tone; + data[cube, position] := hue; + end; + readln; + end; +end; + +procedure sumcolors; +var + cube: blockno; + side: face; +function facepair(aface: face): pair; +begin + case aface of + front, back: facepair := one2; + top, bottom: facepair := three4; + left, right: facepair := five6 + end; +end; + +procedure initializesum; +var + cube: blockno; + side: face; + technicolor: color; +begin + for cube := 1 to 4 do + for side := front to right do + for technicolor := red to white do + sum[cube, facepair(side), technicolor] := 0; +end; + +begin + initializesum; + for cube := 1 to 4 do + for side := front to right do + sum[cube, facepair(side), word(data[cube,side])] := + sum[cube, facepair(side), word(data[cube,side])] + 1; +end; + +procedure find2222; +var + subtotals: array[red..white] of integer; + pair1, pair2, pair3, pair4: pair; + +function two222(pair1, pair2, pair3, pair4: pair): Boolean; +var + hue: color; +begin + for hue := red to white do + subtotals[hue] := + sum[1, pair1, hue]+ + sum[2, pair2, hue]+ + sum[3, pair3, hue]+ + sum[4, pair4, hue]; + if (subtotals[red]=2) and + (subtotals[blue]=2) and + (subtotals[green]=2) and + (subtotals[white]=2) then + two222 := true else + two222 := false; +end; + +procedure listsolution; +begin + halfsolution[1, halfindex] := pair1; + halfsolution[2, halfindex] := pair2; + halfsolution[3, halfindex] := pair3; + halfsolution[4, halfindex] := pair4; + halfindex := halfindex + 1; +end; + +begin + halfindex := 1; + for pair1 := one2 to five6 do + for pair2 := one2 to five6 do + for pair3 := one2 to five6 do + for pair4 := one2 to five6 do + if two222(pair1, pair2, pair3, pair4) then + listsolution; + if halfindex <= 2 then + begin + nosolutions := true; + goto 1; + end; +end; + +procedure simultaneous; +var + done: Boolean; +begin + nosolutions := false; + pointr := 0; + done := false; + repeat + pointr := pointr + 1; + repeat + index := succ(pointr); + if (halfsolution[1, pointr]<>halfsolution[1,index]) and + (halfsolution[2, pointr]<>halfsolution[2,index]) and + (halfsolution[3, pointr]<>halfsolution[3,index]) and + (halfsolution[4, pointr]<>halfsolution[4,index]) then + done := true else + index := index + 1; + until done or (index = pred(halfindex)); + until done or (pointr = halfindex); + if pointr = halfindex then + begin + nosolutions := true; + goto 1; + end; +end; + +procedure rearrange; +var + box: blockno; + a, b: pair; + +procedure put(a, b: pair); +var + old1, new1, old2, new2: face; + save1, save2: alfa; + +procedure oldpair(c: pair); +begin + case c of + one2: + begin + old1 := front; + old2 := back; + end; + three4: + begin + old1 := top; + old2 := bottom; + end; + five6: + begin + old1 := left; + old2 := right; + end + end; +end; +procedure newpair(d: pair); +begin + oldpair(b); + new1 := old1; + new2 := old2; +end; + +begin + newpair(b); + oldpair(a); + save1 := data[box, new1]; + data[box, new1] := data[box, old1]; + data[box, old1] := save1; + save2 := data[box, new2]; + data[box, new2] := data[box, old2]; + data[box, old2] := save2; +end; + +begin + for box := 1 to 4 do + begin + a := halfsolution[box, pointr]; + b := halfsolution[box, index]; + if (a=one2) and (b=five6) then + put(five6, three4) else + begin + if a = three4 then + begin + if b = one2 then + begin + put(one2, five6); + put(three4, one2); + put(five6, three4); + end else + begin + put(three4, one2); + put(five6, three4); + end + end else + if b = one2 then + begin + put(one2, three4); + put(five6, one2); + end else + put(five6, one2); + end; + end; +end; + +procedure correct; +var + list: array[1..8] of integer; + done: Boolean; + side: face; + counter: integer; + +procedure check; +var + delux: array[red..white] of integer; + kolor: color; + counter: integer; +begin + done := true; + for kolor := red to white do + for counter := 1 to 4 do + delux[kolor] := 0; + for counter := 1 to 4 do + begin + delux[word(data[counter,side])] := + delux[word(data[counter,side])] + 1; + if delux[word(data[counter,side])] >= 2 then + done := false; + end; +end; + +procedure rotate; +var + save: alfa; + opposite: face; +begin + if side = back then + opposite := front else + if side = front then + opposite := back else + if side = top then + opposite := bottom else + if side = bottom then + opposite := top; + save := data[list[counter], side]; + data[list[counter], side] := data[list[counter], opposite]; + data[list[counter], opposite] := save; +end; + +begin + list[1] := 4; + list[2] := 3; + list[3] := 4; + list[4] := 2; + list[5] := 4; + list[6] := 3; + list[7] := 4; + list[8] := 3; + for side := back to top do + begin + counter := 0; + check; + while not done do + begin + counter := counter + 1; + rotate; + check; + end; + end +end; + +procedure printout; +var + space: integer; + cube: integer; + side: face; +begin + if nosolutions then + writeln('no solutions') else + begin + writeln('solution to instant insanity'); + for cube := 1 to 4 do + begin + write(cube, ' '); + for side := front to bottom do + write(data[cube, side]); + writeln; + end; + end; +end; + +begin + reset(input, 'insan.d'); + readin; + sumcolors; + find2222; + simultaneous; + rearrange; + correct; +1: + printout; +end. +{ +wbggrb +wbrgrr +wbgwrg +wrgwbr +} diff --git a/tests/numericIO.p b/tests/numericIO.p new file mode 100644 index 0000000000..bcc89f401e --- /dev/null +++ b/tests/numericIO.p @@ -0,0 +1,16 @@ +program numericIO(f,output); + const n = 500; d = 0.12345; + var i: integer; x,s: real; + f: file of real; +begin writeln(clock); + x := 1.0; s := 0; rewrite(f); + for i := 1 to n do + begin write(f,x); s := s+x; x := x+d + end ; + writeln(clock, s); + reset(f); s := 0; + while not eof(f) do + begin read(f,x); s := s+x + end ; + writeln(clock, s) +end . diff --git a/tests/palindromes.p b/tests/palindromes.p new file mode 100644 index 0000000000..026d36412f --- /dev/null +++ b/tests/palindromes.p @@ -0,0 +1,17 @@ +program palindromes(output); + var i,j,l,n,r,s: integer; + p: boolean; + d: array [1..10] of integer; +begin n := 0; writeln(clock); + repeat n := n+1; s := n*n; l := 0; + repeat l := l+1; r := s div 10; + d[l] := s - 10*r; s := r + until s = 0; + i := 1; j := l; + repeat p := d[i]=d[j]; + i := i+1; j := j-1 + until (i>=j) or not p; + if p then writeln(n,n*n) + until n = 10000; + writeln(clock) +end . diff --git a/tests/powersoftwo.p b/tests/powersoftwo.p new file mode 100644 index 0000000000..3dcb776de1 --- /dev/null +++ b/tests/powersoftwo.p @@ -0,0 +1,34 @@ +program powersoftwo(output); +const m = 30; n = 90; { m >= n*log(2) } +var exp,i,j,l: integer; + c,r,t: integer; + d: array [0..m] of integer; {positive powers} + f: array [1..n] of integer; {negative powers} +begin l := 0; r := 1; d[0] := 1; + writeln(clock); + for exp := 1 to n do + begin {compute and print 2**exp } c := 0; + for i := 0 to l do + begin t := 2*d[i] + c; + if t >= 10 then + begin d[i] := t-10; c := 1; + end + else + begin d[i] := t; c:= 0; + end + end ; + if c > 0 then + begin l := l+1; d[l] := 1 + end ; + for i := m downto l do write(' '); + for i := l downto 0 do write(d[i]:1); + write(exp:5, ' .'); + {compute and print 2**(-exp) } + for j := 1 to exp-1 do + begin r := 10*r + f[j]; + f[j] := r div 2; r := r - 2*f[j]; write(f[j]:1) + end ; + f[exp] := 5; writeln('5'); r := 0 + end ; + writeln(clock) +end . diff --git a/tests/pretty.p b/tests/pretty.p new file mode 100644 index 0000000000..66dd2d851b --- /dev/null +++ b/tests/pretty.p @@ -0,0 +1,265 @@ +program pretty(input,output); +const SYMLENGTH = 15; +type + kinds = (ident, number, op, endfile); + symb = array[1..SYMLENGTH] of char; + scanres = record + symbol:symb; + kind:kinds; + end; +var + i,j,k:integer; + ch: char; + tabs: integer; + a: scanres; + working, space, indentflag: boolean; + procflag, inparam, caseflag: boolean; + +procedure indent; +var i:integer; +begin + space := false; + indentflag := false; + writeln; + for i := 1 to tabs do write(' '); +end; + +procedure writesym(a:scanres); +var + i:integer; +begin + if indentflag then indent; + { + if (a.kind = ident) and space then write(' '); + if (a.kind = op) and (a.symbol[1] in ['(','+','-','*']) then write(' '); + } + write(' '); + i := 1; + while (a.symbol[i] <> ' ') do + begin + write(a.symbol[i]); + i := i + 1; + end; + { + if a.kind <> ident then space := false else space := true; + if (a.kind = op) and (a.symbol[1] in [')','+','-','*']) then write(' '); + } +end; + +function scanner:scanres; +var + i:integer; + comment: boolean; + Scanner: scanres; +begin + for i := 1 to SYMLENGTH do Scanner.symbol[i] := ' '; + + repeat + comment := false; + comment := comment; + comment := comment; + comment := comment; + while (ch in [' ', ' ']) and (not eof(input)) do + begin + ch := input^; + get(input); + end; + if ch = '{' then + begin + comment := true; + while ch <> '}' do + begin + ch := input^; + get(input); + end; + ch := ' '; + end; + until not comment; + + if eof(input) then Scanner.kind := endfile + else + begin + if ch in ['a'..'z', 'A'..'Z'] then { identifiers } + begin + i := 1; + while ch in ['a'..'z', 'A'..'Z', '0'..'9'] do + begin + Scanner.symbol[i] := ch; + i := i + 1; + ch := input^; + get(input); + end; + Scanner.kind := ident; + end + else if ch in ['0'..'9'] then { numbers } + begin + i := 1; + while ch in ['0'..'9'] do + begin + Scanner.symbol[i] := ch; + i := i + 1; + ch := input^; + get(input); + end; + Scanner.kind := number; + end + else begin { operators } + Scanner.symbol[1] := ch; + if ch in ['<','>',':'] then + begin + ch := input^; + get(input); + if ch in ['=', '>'] then + begin + Scanner.symbol[2] := ch; + ch := input^; + get(input); + end; + end + else if ch = '.' then + begin + ch := input^; + get(input); + if ch = '.' then + begin + ch := input^; + get(input); + Scanner.symbol := '..'; + end; + end + else + begin + ch := input^; + get(input); + end; + Scanner.kind := op; + end; + end; + scanner := Scanner; +end; + +function compar(s1:symb; s2:symb):boolean; +var + i:integer; + comp: boolean; +begin + comp := true; i := 1; + while (comp and (i <= SYMLENGTH)) do + begin + comp := comp & (s1[i] = s2[i]); + i := i + 1; + end; + compar := comp; +end; + +begin + working := true; + ch := ' '; + procflag := false; + caseflag := false; + inparam := false; + tabs := 0; + while working do + begin + a := scanner; + case a.kind of + endfile: begin + working := false; + writeln; + end; + + ident: begin + if compar(a.symbol, 'begin') then + begin + writesym(a); + tabs := tabs + 1; + indent; + end + else if compar(a.symbol, 'case') then + begin + writesym(a); + tabs := tabs + 1; + caseflag := true; + end + else if compar(a.symbol, 'procedure') or + compar(a.symbol, 'function') then + begin + writeln; + writeln; + writeln; + tabs := 0; + procflag := true; + writesym(a); + end + else if compar(a.symbol, 'var') or + compar(a.symbol, 'type') or + compar(a.symbol, 'const') or + compar(a.symbol, 'label') then + begin + writeln; + tabs := 0; + writesym(a); + end + else if compar(a.symbol, 'of') then + begin + if caseflag then + begin + indent; + writesym(a); + caseflag := false; + end + else writesym(a) + end + else if compar(a.symbol, 'record') then + begin + writesym(a); + tabs := tabs + 1; + indent; + end + else if compar(a.symbol, 'end') then + begin + tabs := tabs - 1; + indent; + writesym(a); + end + else writesym(a); + end; + + number: writesym(a); + + op: begin + if a.symbol[1] = '''' then + begin + write(''''); + while ch <> '''' do + begin + write(ch); + ch := input^; + get(input); + end; + write(ch); + ch := input^; + get(input); + end + else if a.symbol[1] = ';' then + begin + writesym(a); + if not inparam then + indentflag := true + end + else if (a.symbol[1] = '(') & procflag then + begin + inparam := true; + writesym(a); + end + else if a.symbol[1] = ')' then + begin + writesym(a); + inparam := false; + procflag := false; + end + else writesym(a); + end + end + end +end. diff --git a/tests/primes.p b/tests/primes.p new file mode 100644 index 0000000000..17091c5cae --- /dev/null +++ b/tests/primes.p @@ -0,0 +1,30 @@ +program primes(output); +const n = 1000; n1 = 33; (*n1 = sqrt(n)*) +var i,k,x,inc,lim,square,l: integer; + prim: boolean; + p,v: array[1..n1] of integer; +begin writeln(clock); + write(2:6, 3:6); l := 2; + x := 1; inc := 4; lim := 1; square := 9; + for i := 3 to n do + begin (*find next prime*) + repeat x := x + inc; inc := 6-inc; + if square <= x then + begin lim := lim+1; + v[lim] := square; square := sqr(p[lim+1]) + end ; + k := 2; prim := true; + while prim and (k v[k] + end + until prim; + if i <= n1 then p[i] := x; + write(x:6); l := l+1; + if l = 10 then + begin writeln; l := 0 + end + end ; + writeln; writeln(clock) +end . diff --git a/tests/quicksort.p b/tests/quicksort.p new file mode 100644 index 0000000000..a7dce36176 --- /dev/null +++ b/tests/quicksort.p @@ -0,0 +1,31 @@ +program quicksort(output); + const n = 10000; + var i,z: integer; + a: array[1..n] of integer; + + procedure sort(l,r: integer); + var i,j,x,w: integer; + begin {quicksort with recursion on both partitions} + i := l; j := r; x := a[(i+j) div 2]; + repeat + while a[i] < x do i := i+1; + while x < a[j] do j := j-1; + if i <= j then + begin w := a[i]; a[i] := a[j]; a[j] := w; + i := i+1; j := j-1 + end + until i > j; + if l < j then sort(l,j); + if l < r then sort(i,r); + end { sort } ; + +begin z := 1729; {generate random sequence} + for i := 1 to n do + begin z := (131071*z) mod 2147483647; a[i] := z + end ; + writeln(clock); + sort(1,n); + writeln(clock); + for i := 1 to n-1 do + if a[i] > a[i+1] then writeln(i,a[i],a[i+1]); +end . diff --git a/tests/t01.p b/tests/t01.p new file mode 100644 index 0000000000..e8e33d27d4 --- /dev/null +++ b/tests/t01.p @@ -0,0 +1,24 @@ +program graph1(output); +const + d = 0.0625; + s = 32; + h = 34; + c = 6.28318; + lim = 32; +var + x,y: real; + i,n: integer; + +begin + for i := 0 to lim do + begin + x := x/i; + y := exp(-x)*sin(c*x); + n := round(s*y) + h; + repeat + write(' '); + n := n-1; + until n=0; + writeln('*') + end +end. diff --git a/tests/t02.p b/tests/t02.p new file mode 100644 index 0000000000..965ba46425 --- /dev/null +++ b/tests/t02.p @@ -0,0 +1,179 @@ +program graph1(output); +const + d = 0.0625; + s = 32; + h = 34; + c = 6.28318; +var + x,y: real; + i,n: integer; +procedure rdr(var f: text; var x: real); +const + t48 = 281474976710656; + limit = 56294995342131; + z = 27; + lim1 = 322; + lim2 = -292; +type + posint = 0..323; +var + ch: char; + y: real; + a, i, e: integer; + s, ss: boolean; + +function ten(e: posint): real; +var + i: integer; + t: real; +begin + i := 0; + t := 1.0; + repeat + if odd(e) then + case i of + 0: t := t*1.0e1; + 1: t := t*1.0e2; + 2: t := t*1.0e4; + 3: t := t*1.0e8; + 4: t := t*1.0e16; + 5: t := t*1.0e32; + 6: t := t*1.0e64; + 7: t := t*1.0e128; + 8: t := t*1.0e256 + end ; + e := e div 2; + i := i+1; + until e = 0; + ten := t +end ; + +begin + if eof(f) then + begin + message('**tried to read past eos/eof'); + halt + end ; + while (f^ = ' ') and (not eof(f)) do + get(f); + if not eof(f) then + begin + ch := f^; + if ch = '-' then + begin + s := true; + get(f); + ch := f^; + end else + begin + s := false; + if ch = '+' then + begin + get(f); + ch := f^; + end + end ; + if not (ch in ['0'..'9']) then + begin + message('**digit expected'); + halt + end ; + a := 0; + e := 0; + repeat + if a < limit then + a := 10*a + ord(ch)-z else + e := e+1; + get(f); + ch := f^; + until not (ch in ['0'..'9']); + if ch = '.' then + begin + get(f); + ch := f^; + while ch in ['0'..'9'] do + begin + if a < limit then + begin + a := 10*a+ord(ch)-z; + e := e-1; + end ; + get(f); + ch := f^; + end + end; + if ch = 'e' then + begin + get(f); + ch := f^; + i := 0; + if ch = '-' then + begin + ss := true; + get(f); + ch := f^; + end else + begin + ss := false; + if ch = '+' then + begin + get(f); + ch := f^; + end + end; + if ch in ['0'..'9'] then + begin + i := ord(ch)-z; + get(f); + ch := f^; + while ch in ['0'..'9'] do + begin + if i < limit then + i := 10*i + ord(ch)-z; + get(f); + ch := f^; + end + end else + begin + message(' digit expected'); + halt + end ; + if ss then + e := e-i else + e := e+i; + end; + if e < lim2 then + begin + a := 0; + e := 0; + end else + if e > lim1 then + begin + message('**number too large'); + halt + end; + if a >= t48 then + y := ((a+1) div 2) * 2.0 else + y := a; + if s then + y := -y; + if e < 0 then + x := y/ten(-e) else + if e <> 0 then + x := y*ten(e) else + x := y; + end; +end; +begin + for i := 0 to lim do + begin + x := d*i; + y := exp(-x)*sin(c*x); + n := round(s*y) + h; + repeat + write(blank); + n := n-1; + until n=0; + write(aster) + end +end. diff --git a/tests/t03.p b/tests/t03.p new file mode 100644 index 0000000000..7e6acab675 --- /dev/null +++ b/tests/t03.p @@ -0,0 +1,31 @@ +program graph2(output); +const + d = 0.0625; + s = 32; + h1 = 34; + h2 = 68; + c = 6.28318; + lim = 32; +var + i,j,k,n: integer; + x,y: real; + a: array[1..h2] of char; +begin + for j := 1 to h2 do + a[j] := ' '; + for i := 0 to lim do + begin + x := d*i; + y := exp(-x)*sin(c*x); + a[h1] := ':'; + n := round(s*y) + h1; + a[n] := '*'; + if n < h1 then + k := h1 else + k := n; + for j := 1 to k do + write(a[j]); + writeln; + a[n] := ' '; + end +end. diff --git a/tests/t04.p b/tests/t04.p new file mode 100644 index 0000000000..114ed6aa5a --- /dev/null +++ b/tests/t04.p @@ -0,0 +1,47 @@ +program roman(output); +var + x,y: integer; +begin + y := 1; + repeat + x := y; + write(y, ' '); + while x >= 1000 do + begin + write('m'); + x := x-1000 + end; + while x >= 500 do + begin + write('d'); + x := x-500 + end; + while x >= 100 do + begin + write('c'); + x := x-100 + end; + if x >= 50 then + begin + write('l'); + x := x-50 + end; + while x >= 10 do + begin + write('x'); + x := x-10 + end; + if x >= 5 then + begin + write('v'); + x := x-5 + end; + while x >= 1 do + begin + write('i'); + x := x-1 + end; + writeln; + y := 2*y; + until y > 5000 +end. diff --git a/tests/t05.p b/tests/t05.p new file mode 100644 index 0000000000..b273721d61 --- /dev/null +++ b/tests/t05.p @@ -0,0 +1,15 @@ +program egwhile(output); +var + n: integer; + h: real; +begin + n := 10; + write(n); + h := 0; + while n > 0 do + begin + h := h + 1/n; + n := n-1; + end; + writeln(h) +end. diff --git a/tests/t06.p b/tests/t06.p new file mode 100644 index 0000000000..194cd9e1df --- /dev/null +++ b/tests/t06.p @@ -0,0 +1,14 @@ +program egwhile(output); +var + n: integer; + h: real; +begin + n := 10; + write(n); + h := 0; + repeat + h := h + 1/n; + n := n-1; + until n = 0; + writeln(h) +end. diff --git a/tests/t07.p b/tests/t07.p new file mode 100644 index 0000000000..d70a9efb3b --- /dev/null +++ b/tests/t07.p @@ -0,0 +1,12 @@ +program egwhile(output); +var + i,n: integer; + h: real; +begin + n := 10; + write(n); + h := 0; + for i := n downto 1 do + h := h + 1/i; + writeln(h) +end. diff --git a/tests/t08.p b/tests/t08.p new file mode 100644 index 0000000000..9b6f493fea --- /dev/null +++ b/tests/t08.p @@ -0,0 +1,28 @@ +program summing(output); +var + s1, s2p, s2n, s3, s4p, s4n, + lrp, lrn, rlp, rln: real; + i: integer; +begin + s1 := 0; + s2p := 0; + s2n := 0; + s3 := 0; + s4p := 0; + s4n := 0; + for i := 1 to 500 do + begin + lrp := 1/(2*i-1); + lrn := 1/(2*i); + rlp := 1/(10001-2*i); + rln := 1/(10002-2*i); + s1 := s1 + lrp - lrn; + s2p := s2p + lrp; + s2n := s2n + lrn; + s3 := s3 + rlp - rln; + s4p := s4p + rlp; + s4n := s4n + rln; + end; + writeln(s1, s2p-s2n); + writeln(s3, s4p-s4n); +end. diff --git a/tests/t09.p b/tests/t09.p new file mode 100644 index 0000000000..c6543cf5be --- /dev/null +++ b/tests/t09.p @@ -0,0 +1,19 @@ +program sideffect(output); +var + a, z: integer; +function sneaky(x: integer): integer; + begin + z := z-x; + sneaky := sqr(x); + end; +begin + z := 10; + a := sneaky(z); + writeln(a, z); + z := 10; + a := sneaky(10) * sneaky(z); + writeln(a, z); + z := 10; + a := sneaky(z) * sneaky(10); + writeln(a, z); +end. diff --git a/tests/t10.p b/tests/t10.p new file mode 100644 index 0000000000..59487012db --- /dev/null +++ b/tests/t10.p @@ -0,0 +1,29 @@ +program expon2(output); +var + pi, spi: real; + +function power(x: real; y: integer): real; + var + z: real; + begin + z := 1; + while y>0 do + begin + while not odd(y) do + begin + y := y div 2; + x := sqr(x); + end; + y := y-1; + z := x*z; + end; + power := z; + end; +begin + pi := 3.14159; + writeln(2.0, 7, power(2.0, 7)); + spi := power(pi, 2); + writeln(pi, 2, spi); + writeln(spi, 2, power(spi, 2)); + writeln(pi, 4, power(pi, 4)); +end. diff --git a/tests/t11.p b/tests/t11.p new file mode 100644 index 0000000000..0ebececd20 --- /dev/null +++ b/tests/t11.p @@ -0,0 +1,19 @@ +program recursivegcd(output); +var + x, y, n: integer; +function gcd(m,n: integer): integer; + begin + if n=0 then + gcd := m else + gcd := gcd(n, m mod n); + end; +procedure try(a, b: integer); + begin + writeln(a, b, gcd(a, b)); + end; +begin + try(18, 27); + try(312, 2142); + try(61, 53); + try(98, 868); +end. diff --git a/tests/t12.p b/tests/t12.p new file mode 100644 index 0000000000..0845f882e7 --- /dev/null +++ b/tests/t12.p @@ -0,0 +1,24 @@ +program records(output); +type + cmplx = record + rp: real; + ip: real; + end; +var + x, y: cmplx; +function cadd(a,b: cmplx): cmplx; + begin + cadd.rp := a.rp + b.rp; + cadd.ip := a.ip + b.ip; + end; +procedure cprint(a: cmplx); + begin + writeln(a.rp, '+', a.ip, 'i'); + end; +begin + x.rp := 1; + x.ip := 2; + y.rp := 3; + y.ip := 4; + cprint(cadd(x, y)); +end. diff --git a/tests/t13.p b/tests/t13.p new file mode 100644 index 0000000000..a825a95fe7 --- /dev/null +++ b/tests/t13.p @@ -0,0 +1,56 @@ +program rec(output); +type + alfa = packed array[1..10] of char; + status = (married, widowed, divorced, single); + date = record + mo: (jan, feb, mar, apr, may, jun, + july, aug, sept, oct, nov, dec); + day: 1..31; + year: integer + end; + person = record + name: record + first, last: alfa + end; + ss: integer; + sex: (male, female); + birth: date; + depdts: integer; + case ms: status of + married, widowed: ( + mdate: date); + divorced: ( + ddate: date; + firstd: boolean); + single: ( + indepdt: boolean) + end; +var + pp: person; + p: ^person; +begin + pp.name.last := 'woodyard'; + pp.name.first := 'edward'; + pp.ss := 845680539; + pp.sex := male; + pp.birth.mo := aug; + pp.birth.day := 30; + pp.birth.year := 1941; + pp.depdts := 1; + pp.ms := single; + pp.indepdt := true; + + new(p); + p^.name.last := 'woodyard'; + p^.name.first := 'edward'; + p^.ss := 845680539; + p^.sex := male; + p^.birth.mo := aug; + p^.birth.day := 30; + p^.birth.year := 1941; + p^.depdts := 1; + p^.ms := single; + p^.indepdt := true; + if pp = p^ then + writeln(true); +end. diff --git a/tests/t14.p b/tests/t14.p new file mode 100644 index 0000000000..621a99cdc0 --- /dev/null +++ b/tests/t14.p @@ -0,0 +1,42 @@ +program rec(output); +type + alfa = packed array[1..10] of char; + status = (married, widowed, divorced, single); + date = record + mo: (jan, feb, mar, apr, may, jun, + july, aug, sept, oct, nov, dec); + day: 1..31; + year: integer + end; + person = record + name: record + first, last: alfa + end; + ss: integer; + sex: (male, female); + birth: date; + depdts: integer; + case ms: status of + married, widowed: ( + mdate: date); + divorced: ( + ddate: date; + firstd: boolean); + single: ( + indepdt: boolean) + end; +var + p: ^person; +begin + new(p); + p^.name.last := 'woodyard'; + p^.name.first := 'edward'; + p^.ss := 845680539; + p^.sex := male; + p^.birth.mo := aug; + p^.birth.day := 30; + p^.birth.year := 1941; + p^.depdts := 1; + p^.ms := single; + p^.indepdt := true; +end. diff --git a/tests/t15.p b/tests/t15.p new file mode 100644 index 0000000000..9cdd3cbf55 --- /dev/null +++ b/tests/t15.p @@ -0,0 +1,16 @@ +program main(output); +const + size = 10; +var + aset: set of 1..size; + i, j: integer; +begin + aset := []; + for i := 1 to size do + begin + aset := [i]+aset; + for j := 1 to size do + if j in aset then + writeln(i,j); + end; +end. diff --git a/tests/t16.p b/tests/t16.p new file mode 100644 index 0000000000..78dedb734c --- /dev/null +++ b/tests/t16.p @@ -0,0 +1,21 @@ +program main(input, output); +procedure copy(inp, out: text); + var + c: char; + begin + while not eof(inp) do + begin + while not eoln(inp) do + begin + c := inp^; + out^ := c; + put(out); + get(inp); + end; + writeln; + get(inp); + end; + end; +begin + copy(input, output); +end. diff --git a/tests/t17.p b/tests/t17.p new file mode 100644 index 0000000000..3a2b777282 --- /dev/null +++ b/tests/t17.p @@ -0,0 +1,20 @@ +program graph1(output); +const + d = 0.0625; + s = 32; + h = 34; + c = 6.28318; + lim = 32; +var + x,y: real; + i,n: integer; + +begin + for i := 0 to lim do + begin + x := d*i; + y := exp(-x)*sin(c*x); + n := round(s*y) + h; + writeln('*':n); + end +end. diff --git a/tests/t18.p b/tests/t18.p new file mode 100644 index 0000000000..7b62dac65e --- /dev/null +++ b/tests/t18.p @@ -0,0 +1,12 @@ +program main(output); +type + t = record + a: real; + b: integer; + end; +var + x: t; +begin + x := t(1.0, 1); + writeln(x.a, x.b); +end. diff --git a/tests/t19.p b/tests/t19.p new file mode 100644 index 0000000000..482bd20a13 --- /dev/null +++ b/tests/t19.p @@ -0,0 +1,55 @@ +program main(input,output); +var + o, z: set of 1..1; +begin + o := [1]; + z := []; + if o < z then + writeln('o < z'); + if o <= z then + writeln('o <= z'); + if o = z then + writeln('o = z'); + if o <> z then + writeln('o <> z'); + if o >= z then + writeln('o >= z'); + if o > z then + writeln('o > z'); + if z < o then + writeln('z < o'); + if z <= o then + writeln('z <= o'); + if z = o then + writeln('z = o'); + if z <> o then + writeln('z <> o'); + if z >= o then + writeln('z >= o'); + if z > o then + writeln('z > o'); + if o < o then + writeln('o < o'); + if o <= o then + writeln('o <= o'); + if o = o then + writeln('o = o'); + if o <> o then + writeln('o <> o'); + if o >= o then + writeln('o >= o'); + if o > o then + writeln('o > o'); + if z < z then + writeln('z < z'); + if z <= z then + writeln('z <= z'); + if z = z then + writeln('z = z'); + if z <> z then + writeln('z <> z'); + if z >= z then + writeln('z >= z'); + if z > z then + writeln('z > z'); +end. -- 2.20.1