Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Notes:

1) The times are real times (including I/O) and they are in seconds.

2) The self compilation test is the time to compiler an early version
2) The self compilation test is the time to compile an early version
of the BCPL compiler, typically using the commands:

bcpl com/origbcpl.b to origbcpl
Expand Down
4 changes: 2 additions & 2 deletions TGZDATE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

Distributed from machine: solestreet
Mon Jul 27 13:17:46 BST 2015
Distributed from machine: mikeh-OptiPlex-745
Mon Feb 15 09:29:00 AEDT 2021
14 changes: 12 additions & 2 deletions bcplprogs/demos/countdn.b
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and intermediate results must be integral and in the range 0 to 999.

Written in BCPL by Martin Richards (c) February 2000
*/
/* TODO MJH
to make useful in 2021 : supply the target number and highlight in the output stream
Also try to document this source : useful exercise in relearning the language
*/

GET "libhdr"

Expand Down Expand Up @@ -40,7 +44,7 @@ LET start() = VALOF
FOR j = 0 TO Upb DO p!j := 0
v!i := p
}

/* work on the outstream lines separately */
outstream := 0
IF argv!6 DO outstream := findoutput(argv!6)
IF outstream DO selectoutput(outstream)
Expand Down Expand Up @@ -128,8 +132,14 @@ AND setbit(bits, n) BE
IF new=old RETURN
bitv!p, change := new, TRUE
UNLESS resv!n DO
writef("adding %i4 to set %b6 %s %n %n*n",
/* changed order of last 3 to ease reverse engineering [MJH]
writef("adding %i4 to set %b6 %s %n %n*n",
n, bits, opstr, vala, valb)
*/
/* suggest adding a test here for the target number : if eq then chnage string adding
*/ IF n=162 writef("->>")
writef("adding %i4 to set %b6 %n %s %n*n",
n, bits, vala, opstr, valb)

resv!n := TRUE
}
Expand Down
114 changes: 114 additions & 0 deletions bcplprogs/demos/countdn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Boot tracing level is set to 1

cintsys 06 Sep 2014 13:49

bytestr=ABCD1234 word 0 = 44434241
BIGENDER is not defined but the host machine is a big ender
sizeof(int) = 4
sizeof(long) = 8
sizeof(BCPLWORD) = 4
sizeof(BCPLWORD *) = 8
FormD is "d"
FormX is "X"
Cintcode memory (upb=4000000) allocated
Environment variable BCPLROOT = /home/mikeh/bcpl/cintcode
Environment variable BCPLPATH = /home/mikeh/bcpl/cintcode/cin
Environment variable BCPLHDRS = /home/mikeh/bcpl/cintcode/g
Environment variable BCPLSCRIPTS = (null)
Boot's stack allocated at 821
Boot's global vector allocated at 1337
Rootnode allocated at 100
Loading all resident programs and libraries
osfname: syscin/boot => syscin/boot
Trying: syscin/boot in the current directory - not found
pathinput: attempting to open syscin/boot using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/syscin/boot => /home/mikeh/bcpl/cintcode/cin/syscin/boot
Trying: /home/mikeh/bcpl/cintcode/cin/syscin/boot - found
syscin/boot loaded successfully
osfname: syscin/blib => syscin/blib
Trying: syscin/blib in the current directory - not found
pathinput: attempting to open syscin/blib using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/syscin/blib => /home/mikeh/bcpl/cintcode/cin/syscin/blib
Trying: /home/mikeh/bcpl/cintcode/cin/syscin/blib - found
syscin/blib loaded successfully
osfname: syscin/syslib => syscin/syslib
Trying: syscin/syslib in the current directory - not found
pathinput: attempting to open syscin/syslib using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/syscin/syslib => /home/mikeh/bcpl/cintcode/cin/syscin/syslib
Trying: /home/mikeh/bcpl/cintcode/cin/syscin/syslib - found
syscin/syslib loaded successfully
osfname: syscin/dlib => syscin/dlib
Trying: syscin/dlib in the current directory - not found
pathinput: attempting to open syscin/dlib using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/syscin/dlib => /home/mikeh/bcpl/cintcode/cin/syscin/dlib
Trying: /home/mikeh/bcpl/cintcode/cin/syscin/dlib - found
syscin/dlib loaded successfully
Calling the interpreter
BOOT stack is at 821
BOOT global vector is at 1337
CLI stack allocated at 8339
CLI global vector allocated at 8855

BCPL 32-bit Cintcode System (30 May 2013)
boot about to call the interpreter recursively
It should start executing the boot function: startroot
boot: about to call sys(Sys_interpret,...)
startroot: can now use normal stream i/o
startroot: trying to load syscin/cli
osfname: syscin/cli => syscin/cli
Trying: syscin/cli in the current directory - not found
pathinput: attempting to open syscin/cli using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/syscin/cli => /home/mikeh/bcpl/cintcode/cin/syscin/cli
Trying: /home/mikeh/bcpl/cintcode/cin/syscin/cli - found
startroot: loaded syscin/cli successfully
startroot: now entering the cli
cli: now entering the main CLI loop
0.000> countdn 3 1 10
osfname: countdn => countdn
Trying: countdn in the current directory - found
adding 3 to set 000001 num 3 0
adding 1 to set 000010 num 1 0
adding 10 to set 000100 num 10 0

The given numbers are:

1 3 10

Doing closure
adding 4 to set 000011 add 3 1
adding 2 to set 000011 sub 3 1
adding 13 to set 000101 add 3 10
adding 7 to set 000101 sub 10 3
adding 30 to set 000101 mul 10 3
adding 11 to set 000110 add 1 10
adding 9 to set 000110 sub 10 1
adding 8 to set 000111 add 1 7
adding 6 to set 000111 sub 7 1
adding 14 to set 000111 add 1 13
adding 12 to set 000111 sub 13 1
adding 31 to set 000111 add 1 30
adding 29 to set 000111 sub 30 1
adding 20 to set 000111 mul 10 2
adding 5 to set 000111 div 10 2
adding 40 to set 000111 mul 10 4
adding 27 to set 000111 mul 9 3
adding 33 to set 000111 mul 11 3
The following numbers can be computed:

1 2 3 4 5 6 7 8 9 10
11 12 13 14 20 27 29 30 31 33
40
0.077> logout
osfname: logout => logout
Trying: logout in the current directory - not found
pathinput: attempting to open logout using
BCPLPATH = /home/mikeh/bcpl/cintcode/cin
osfname: /home/mikeh/bcpl/cintcode/cin/logout => /home/mikeh/bcpl/cintcode/cin/logout
Trying: /home/mikeh/bcpl/cintcode/cin/logout - found
interpreter returned control to cintsys, res=0

Expand Down
6 changes: 3 additions & 3 deletions bcplprogs/demos/floyd.b
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ LET start() = VALOF
}

n, e, initseed := 5, 2, 1
IF argv!0 & string.to.number(argv!0) DO n := result2
IF argv!1 & string.to.number(argv!1) DO e := result2
IF argv!2 & string.to.number(argv!2) DO initseed := result2
IF argv!0 & str2numb(argv!0) DO n := result2
IF argv!1 & str2numb(argv!1) DO e := result2
IF argv!2 & str2numb(argv!2) DO initseed := result2

IF n<2 DO n := 2
IF e>n DO e := n
Expand Down
Empty file modified bcplprogs/demos/mctest.b
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions bcplprogs/demos/splay.b
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ LET start() BE
update(@root,'C', 'c')
update(@root,'D', 'd')
update(@root,'E', 'e')
// update(@root,'A', 'a')
printree(root)

update(@root,'F', 'f')
Expand Down
19 changes: 19 additions & 0 deletions bcplprogs/demos/template.b
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GET "libhdr"

LET start() = VALOF
{ LET argv = VEC 50
LET len = VEC 2

IF rdargs("A/A,B/A,C/A", argv, 50) = 0
{ writes("Bad arguments: triangles need three numbers*n")
RESULTIS 20
}
FOR i = 0 TO 2 DO len!i := str2numb(argv!i)
writes("*nTriangle given: ")
FOR i = 0 TO 2 DO writef("*n%n ", len!i)
writef("*n ")
writef("*nThis is %s triangle*n",
sort_of_triangle(len!0, len!1, len!2))
}

AND sort_of_triangle(a, b, c) = "test"
6 changes: 3 additions & 3 deletions bcplprogs/demos/triangle.b
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ LET start() = VALOF
LET len = VEC 2

IF rdargs("A/A,B/A,C/A", argv, 50) = 0
{ writes("Bad arguments: triangle need three numbers*n")
{ writes("Bad arguments: triangles need three numbers*n")
RESULTIS 20
}
FOR i = 0 TO 2 DO len!i := str2numb(argv!i)
writes("*nTriangle given: ")
FOR i = 0 TO 2 DO writef("%n ", len!i)
FOR i = 0 TO 2 DO writef("*n%n ", len!i)
writef("*nThis is %s triangle*n",
sort_of_triangle(len!0, len!1, len!2))
RESULTIS 0
Expand All @@ -22,6 +22,6 @@ AND sort_of_triangle(a, b, c) =
// At this point we know that a <= b <= c
c>a+b -> "not a",
a=c -> "an equilateral",
a=b | b=c -> "an isoscelese",
a=b | b=c -> "an isosceles",
c*c=a*a+b*b -> "a right angled",
"a scalene"
2 changes: 1 addition & 1 deletion bcplprogs/edsac/edsac.b
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GET "libhdr"
//Memory:

// 512 35-bit words with even addresses, split into two 17-bit halves
// with one seperator bit.
// with one separator bit.

// | 17 bits | 1 bit gap | 17 bits |
// 2n+1 2n S access, 17 bits
Expand Down
Loading