                   INFORMAL DAILY NOTES

                           by
                     Martin Richards
		    Started July 2019
		   Updated 12 Feb 2021


This is an informal collection of notes to remind me of what changes
I have made to the various systems on my home page. The file is located
here since I frequently modify the BCPL compiler or some of the
commands such as com/playmus.b although these note are not limited
to just these systems.

Currently these notes are being written on my Dell Inpiron 13 laptop
running Ubuntu Linux on a Virtual Box under Windows 10 Pro.

13/02/2021
Recently I made significant changes to the BCPL distribution but
unfortunate it stopped it working. The version on my web page became
unreliable and so I have just replaced it with a slightly modified
earlier version and I will make the planned changes more
carefully. These mainly concern interfacing with the more recent SDL
and Openg GL libraries. Hopefully SDL2 and OpenGL version 3.1 and
later will be provided.

Two recent addition that may be of interest, they are
bcplprogs/raspi/hdmandset.b to display very fine detail of the
Mandelbrot set and bcplprogs/genome/dnaplot.b which is a experiment
that attempts to display a 3D images of versions of the Coronavirus
DNA molecule.

01/03/2020
Added the TRn debugging command to trace the execution of the next
n Cintcode instructions. The implementaion needs a little more
work particularly for 64 bit BCPL.

I am planning to add a new section to the BCPL manual to illustrate
various debugging techniques using com/bugrast2wav.b as an example.
This is an early bugridden draft of com/rast2wav.b which uses the
rastering data, typically in RASTER, to generate a sound file in
.wav format. RASTER is typically created with the aid of the raster
command running under rastsys.

10/02/2020

I have been working on raster.b, rast2ps.b and rast2wav.b. These now seem
to be working and the following command sequences should work, provided the
relevant commands have been installed.


ctrl-c
cd $BCPLROOT
rastsys
raster
origbcpl com/origbcpl.b to junk
ctrl-c
cintsys
rast2wav to origbcpl.wav
rast2ps to origbcpl.ps
ctrl-c
ps2pdf origbcpl.ps to origbcpl.pdf incl origbcplps.h

The .wav file can be played or converted to .mp3 using

audacity origbcpl.pdf

and the .pdf file van be viewed using

okular origbcpl.pdf

Replacing origbcpl by bcpl in the above commands works for the
current bcpl compiler conpiling itself.

Replacing origbcpl with sortdemo also produces interesting results.

rastsys
raster
sortdemo 50000
ctrl-c
cintsys
rast2wav to sortdemo.wav
rast2ps to sortdemo.ps
ctrl-c
ps2pdf sortdemo.ps to sortdemo.pdf



25/01/2020
Cleaning up and testing most of the Makefiles. The modified Makefile
are as follows.

25/01/2020 Makefile
The primary makefile slightly modifed for most of the others.

25/01/2020 MakefileSDL
Only 2 changes from Makefile. Example

make -f MakefileSDL vclean
make -f MakefileSDL
ctrl-c
cd ../bcplprogs/raspi
cintsys
c b engine
engine

SDL also works on 64 bit BCPL. Example

make -f MakefileSDL vclean
make -f MakefileSDL run64
ctrl-c
cd ../bcplprogs/raspi
cintsys64
c b engine
engine

25/01/2020 MakefileGL
Only 2 changes from Makefile. Needs substatial developement because
the OpenGL interface will now take advantage of BCPL floating point.

25/01/2020 MakefileRaspiGL
Only 2 changes from Makefile. Needs substatial developement because
the OpenGL interface will now take advantage of BCPL floating point.

25/01/2020 MakefileGywin
Only 2 changes from Makefile. Not yet tested but is probably works.

25/01/2020 MakefileMacOSX
Only 2 changes from Makefile. Not tested - problably does not work.

2 Nov 2019
I plan to one version of the interpreter (sysc/cinterp.c) which will
be used to create three variants.

fasterp.o    if FASTERPyes is defined
rasterp.o    if RASTERINGyes is defined
cinterp.o    if CINTERPyes is defined.

This requires substantial change to cinterp.c and minorechanges to
the Makefiles. If TARGET64 is defined they will work with 64 bit
Cintcode.

Rastering used the macros Rb(a), Rh(a) and Rw(a). When RASTERPyes
is not defined there have empty defintions.

cinterp is the standard interpreter providing tallying, the watch
feature and some address checking. fasterp was originally a hand
written assembly code version of cinterp without most of the debugging
aid. This was later replaced by a version in C with few debugging
aids. Both interpreters are resident and the choice of which is used
can be switched using the interpreter command. cinterp defines the
function interpreter and fasterp defined cintasm (for historical
reasons). rasterp is like fasterp in that it defines a version of
the function cintasm.

cintsys cobines cinterp and fasterp while rastsys combines cinterp
and raserp.

These changes will be delayed until the more pressing problem of
making 32 and 64 bit cintpos run on 64 bit machines. This involves
changes similar to those applied to cintsys, typically providing two
BCPL word for each machine address held in BCPL space. For cintpos
there are rather more places where this must be done. In due course
the use of Pthreads will be removed from cintpos.

09/12/2019
Added the following commands:

bbcbcpl      Compile BBC BCPL used on the BBC Microcomputer
             to 16 bit BBC Cintcode

bbcbcpl32    Compile BBC BCPL used on the BBC Microcomputer
             to modern 32 bit BBC Cintcode. BBC BCPL equates
	     upper and lower case lettern in identifiers and
	     reserved words, but this version does not. But it
	     allows reserved words to be in either upper or
	     lower case.

mapcode      A program to convert BBC 16 Cintcode into a more
             readable form.  See bcplprogs/bbcmicro/ for more
	     details.

There is a new directory bbcmicro in bcplprogs/. This contains
an experimental reconstruction of the RCP BCPL System for the
BBC Microcomputer. The main purpose of this work is to possibly
help with the reimplementation of the BBC Domesday Project that
was written in 1965 to run on BBC Microcomputers using a Phillips
12" laser disc.

The standard BCPL Cintcode compiler has been modified to disallow
section separating dots in GET file.

04 Jan 2020
I am eliminating the use of the macros FormD and FormX used in
cintsys/sysc. They were defined in the file INT.h that is created by
the program sysc/mkint-h.c and used in printf format strings. These
printf calls now convert arguments to type long long and use
substitution items such as %lld and %llX. This has been done since
long has length 64 under Linux but 32 under windows, but long long
has length 64 on both systems.

There are many programs to change and when this is done INT.h will
no longer define FormD and FormX. For convenience the macro LL
is defined in cintsys.h to be the cast (long long).

The recently added command bbcbcpl32 will soon be removed, in favour
of using the bbc2bcpl and bcpl commands.

To help with the experimental reconstruction of the BBC Domeday
Project the default global vector size from 1000 to 2000.

06/01/2020
Updated com/stats.b to handle FLTOP, MW, SELLD and SELST.
Moved the handling of Sys_tally into cinterp.c from cintsys.c.

preload bcpl
stats on
bcpl com/bcpl.b to junk
stats stats
stats profile
stats analysis

All work and tells us that the self compilation of the BCPL compiler
takes 41273342 Cintcode instruction executions. This takes about
0.478 secs on my Dell laptop. So on average it executes about
86,345,000 Cintcode instructions per second.

My processor is described as

Intel i5-8250U CPU
1.60 GHz 1.80 GHz

64-bit Operating System, x64-based processor

The test was run under 32-bit BCPL Cintcode.

30/09/2019
To cause #include <GL/glext.h> to declare the OpenGL prototypes such
as glCreateProgram it must be preceeded by #define
GL_GLEXT_PROTOTYPES.  This must preceed #include <GL/gl.h>.

I am modifying the OpenGL interface to work under both 32 and 64 bit
BCPL.  Even under 64 bit BCPL I plan to pass 32 bit floats to
OpenGL. Models specified by .mdl files will create structures
containing 32 bit floats is the vector holding the vertex data. On 64
bit BCPL thease floats will be packed two per BCPLWORD. The .mdl files
will need no change but loadmodel defined in g/gl.b needs to be
modified.

In gl.b added or modified push32, put32, get32, push16, put16 and
get16.  These are used in loadmodel. rdflt32 was also added. The
vector in the model structure are not used directly by gl.b but are
just passed to OpenGL by sys(Sys_gl,...) calls. get32 and get16 are
only there to aid debugging.

Under Oracle VM VirtualBox under Windows 10 I have Ubuntu Linux 18.04 LTS.
On it I can run 32 bit BCPL Cintcode using cintsys, and 64 bit BCPL code
using cintsys64. I plan to enable my BCPL OpenGL programs to run on
both of these using the same BCPL source code.

TARGET64 is conditionally set in cintsys.h. When set the C programs are
compiled for 64 bit Cintcode. It affects the definitions of B2Wsh, BCPLWORD,
BCPLFLOAT, etc using definitions in INT.h (created by mkint-h.c). It also
affect the defintions of macros sych a Csin and Ccos giving sin, sinf, cos
or cosf.

N2F(a) is (*(BCPLFLOAT*)&)(a) and F2N(a) is (*(BCPLWORD*)&)(a) are
defined in cintsys.h to allow conversion between BCPL words and
floafting point values of the same length. They must be applied to
variables, eg N2F(a2). Originally, this conversion was done using a
union and assignments. This mechanism is better since it probably
compiles no code because the BCPL value and C number both have the
same bit pattern.

20/09/2019
32 and 64 bit BCPL now seems to work on both 32 and 64 bit machines.
32 bit BCPL evaluates constants using 32 bit arithmetic so it cannot
compile floating point numbers into 64 bit Cintcode and will also fail
to compile some large integers correctly. For similar reasons 64 bit
BCPL will fail when compiling to 32 bit Cintcode. The programs boot.b,
blib.b, dlib.b, cli.b, c.b and bcpl.b do not contain floating point
constants and the few large integer constants that compiled
incorrectly int 64 bit Cintcode would not stop an initial version of
cintsys64 from working. These errors can be corrected by running
compall64 under cintsys64.

Correct compilations of these programs are held in enderlit/ and
enderbig/ and in enderlit64/ and enderbig64/. These directories also
hold safe versions of these Cintcode files created by the scripts
copysafe and copysafe64. These copies are not vital for the 64 bit
system since they can be rebuilt using cintsys. The safe versions are
more important for the 32 bit system where rebuiding them without
cintsys is more difficult.

Some of the programs compiled by compall cannot be compiled correctly
for 64 bit Cintcode using cintsys. The compilation of these programs
have been commented out in compall64. They can be compiled under
cintsys64 using compflts64.

09/09/2019
Currently the 32 bit BCPL compiler can only compiler 32 bit floating
point values and the 64 bit compiler can only compile 64 bit floating
point numbers. It requires a modification to Ocode and a lot of work
to change this and so I plan to leave it as it is. The test program
fcmpltest.b will only compile without errors using the appropriate
compiler.

4/9/2019
Cleaning up the compilation scripts.
If neither t32 or t64 is specified for a bcpl call the target word
is the same as the current BCPL word length. t32 or t64 is set
appropriately.

If tcb is zero the current system is cintsys or cintsys64 otherwise it
is cintpos or cintpos64.  The headers environment variable name is
specified by the hdrs argument to bcpl. If hdrs is not specified it is
set as follows:

BCPLHDRS    if t32 and tcb is zero
BCPL64HDRS  if t64 and tcb is zero
POSHDRS     if t32 and tcb is non zero
POS64HDRS   if t64 and tcb is non zero

So the headers variable is by default appropriate for the current
system and target word length.

The hdrs argument is required if compiling under cintsys or cintsys64
for cintpos or cintpos64.

In all cases if t64 is set and the destination file name starts with
cin/ it is automatically replaced by the compiler with cin64/.

2/9/2019
32 bit Cintpos now seems to work under 64 bit linux 18.04 LTS under Windows 10.
tcpcli works. cmpltest, fcmpltest and fltcmpltest all work.
32 bit cintsys works as above, and cmpltest, fcmpltest and fltcmpltest all work.
64 bit cintsys works as above, and cmpltest, fcmpltest and fltcmpltest all work.
In directory Cintpos/cintpos
make bin/cintpos64 works
cintsys64             ok
c compall64 hard      ok
^c
cintpos64             can't load syslib -- copied from BCPL/cintcode
cintsys64             Hangs up after outputing
64 bit Cintpos System (2 Sep 2019)
It ignores all characters but ^C causes it to enter debug
In debug
120=   crashes but
120$x= works
Removed returncode from libhdr.h and all references to it.
Cintsys and Cintpos both now use the same libhdr.h file.

BCPLHDRS and BCPL64HDRS are the same at the moment, and so
are POSHDRS and POS64HDRS.

I am thinking of making bc and bs compile for a target of the same word
length as the current system. This will probably be an incompatible
change requiring a new directory cin32 and the automatic replacement
of cin/ by cin32/ or cin64/ in the compiler. There will be command-commands
bc, bc32, bc64, bs, bs32 and bs64 and they will all use the same environment
variables. I am currently not sure this is a good idea.

03/09/2019
Modified bcplfe.b to automatically change cin/ to cin64/ if t64 is specified.

Now working on the scripts b bc bs bc64 bs bs32 bs64 in both directories
BCPL/cintcode and Cintpos/cintpos.

Doing those in BCPL/cintcode first

b is designed to compile a program in the current directory sending the
compiled code to the same directory. If the current system has a 32 bit
word length the compiled code will be for a 32 bit system, otherwise it
copiles 64 bit code. b ia as follows:

.k file/a,opt
echo "bcpl <file>.b to <file> <opt>"
bcpl <file>.b to <file> <opt>

The BCPL header will be appropriate for the currently running system, ie
BCPLHDRS or BCPL64HDRS as appropriate. The opt argument allows other bcpl
command arguments to be supplied.

b seems to work.

bc will compile a program in the com/ directory sending the compiled code
to directory cin/ or cin64/ depending on the currently running system. It
will specify BCPLHDRS or BCPL64HDRS as appropriate. It implementation is
as follows:

.k file/a,opt
echo "bcpl com/<file>.b to cin/<file> <opt>"
bcpl com/<file>.b to cin/<file> <opt>

bs is similar to bc but compiles system files from sysb/ to cin/syscin/
or cin64/syscin/ as appropriate.

By running cintsys or cintsys64 with the -f option you can check that
the right environment variables are being used both for loading programs
and finding header files.

If you definitely wish to generate 64 bit code when using either cintsys
or cintsys64, you can use b64, bc64 or bs64. These are like b, bc and bs
but add the t64 option when calling the compiler.

b, bc and bs assume that the 32 and 64 bit headers files are identical.
If they are not, yoe should use b32, bc32, b64 or b64, bc64, bs64
explicitly since these specify the appropriate headers environment
variables.

Finally, for system pruposes, there are scripts to compile files
into the directories enderlit/ and enderbig/ for little ender and
bigender architectures. Currently the all assume they are running
on a little ender machine. These scripts are bcl32, bcb32, bcl64,
bcb64 and bsl32, bsb32, bsl64 and bsb64. They are only available
in directory BCPL/cintcode/. The directories enderlit/ and enderbig/
only needed when building cintsys or cintsy64 for the first time.
The system code for cintpos and cintpos64 is compiled when needed
using cintsys ans cintsys64.

1/9/2019
Checking that sadebug defined in BCPL/cintcode/sysb/boot.b works for
both 32 and 64 bit BCPL.

21/08/2019
I decided to modify Cintpos so that it no longer relied on Pthread.  The
plan is to use polling instead. The Cintcode interpreter will give
control to a function called pollrtn approximately once every
millisecond. It will repeatedly estimate how many Cintocde
instructions can be executed in one millisecond. pollrtn will only be
called when Cintcode interrupts are enabled. It will disable interrupt
and then give control to each coroutine in devwaitlist.  This list
will only contain coroutines belonging to devivcs the are currently
waiting of an event. In the first implementation only three event type
will be provided. These are (1) waiting for the time to return a
packet from the clock device to a requestion task. (2) return a packet
containg the next character from a keyboard to the rquesting task and
(3) waiting for data to be sent or received via a TCP/IP connection.

The effect of this change will cause Cintpos to run as a single thread
elimination the need for multithreading computations including the
need to use mutexes, conditional waits, and inter thread
comunications. The use of a single thread and coroutines will greatly
simplify the implementation of devices

As far as the user is concerned the semantics of qpkt, taskwait and
the interaction with the Cintpos devices will be the same as
before. Hopefully the system will be simpler, more machine independent
and reliable, and should even have improved performance..

The current problem compiling 32 bit cintpos on a machine with 64 bit
address is that they are incompatible with 32 bit BCPL words. This has
a fix long ago for file pointers but the implementation of devices.c
has many problems that are not so easy to correct.


On a completely different matter, on some system inet_hton caused
a warning be it had not been declares. Inserting
#include <arpa/inet.h> seemed to solve the problem.

19/08/2019
Had difficulty connecting VirtualBox Ubuntu Linux to the internet even
though ping ely.cl.cam.ac.uk worked.
In Ubuntu64-18-08-2019 clicked on
Devices->Network->Network Settings..->Network
and selected: Bridged Adapter in the Attached to box.
Then exitted from and restarted Ubuntu64-18-08-2019.
After that ping ely.cl.cam.ac.uk worked.

Even after changeing back from Bridged Adapter to NAT and restarting
VirtualBox, ping elay.cl.cam.ac.uk still worked. I am puzzled.

I can login to ely from home using ssh but cannot when in the Lab.
I can login to ely at the Lab using: ssh mr10@slogin-otpw.cl.cam.ac.uk

17/08/2019
I have progressed well installing Ubuntu 18.04 LTS under VirtualBox
on my Dell Windows 10 laptop.
I can now read and write to a memory stick.
ssh now works and I can login to ely.cl, and no doubt commands like
make sshpube to update the BCPL distribution will work.
The Linux directory ~/share or /home/mr/share is shared with the
windows 10 directory C:\share.
Edited bcplman.tex and updates bcplman.pdf but had to add -o user=mr10
to the scp command in make sshpube.
Installed synaptic and texlive-full.

29/07/2019
Added rootnode field hostaddrsize to hold the size in bits of a
value of type BCPLWORD* in C on the host machine, and implemented
sysinfo.b to output this value and other details.

28/07/2019
Copied bcpl.tgz, cintpos.tgs and musprogs.tgz from my home page and
expanded them into BCPL, Cintpos and Musprogs in the distribution
directory. On this system my user id is mr and my home directory
under cygwin is /home/mr. $HOME is equal to /home/mr. I found it
necessary to replace /home/mr10 by $HOME in some of the make files.

I created the directory /dose as used on many of my older systems
and has to install zip to run under cygwin. Having done that the
commands

cd
cd distribution/BCPL
make dose

Successfuly created bcpl.tgz and bcpl.zip in /dose.


(Enf of file)
