From 44adc69be84881253d896a4758240da03ed3946b Mon Sep 17 00:00:00 2001 From: Noah Smith Date: Sun, 22 Sep 2024 08:26:35 +0200 Subject: [PATCH] algebra1 --- _posts/2024-09-22-algebra1.md | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 _posts/2024-09-22-algebra1.md diff --git a/_posts/2024-09-22-algebra1.md b/_posts/2024-09-22-algebra1.md new file mode 100644 index 0000000..533495b --- /dev/null +++ b/_posts/2024-09-22-algebra1.md @@ -0,0 +1,68 @@ +--- +layout: post +title: "algebra1" +--- +target is using python, fortran10, macro10 in parallel to reproduce [feynman's table 22-3](https://www.feynmanlectures.caltech.edu/I_22.html). for python things are straightforward. + + y = .00225 + x = round(sqrt(1. - y**2), 7) + for _ in range(11): + print('%10.5f %10.5f' % (x, y)) + x2 = round(x**2 - y**2, 7) + y2 = round(2 * x * y, 7) + x, y = x2, y2 + +with fortran10, the basic workflow for iterating between raspi and tops10 is there now. what would be nice is to be able to at the least do 'initial work' on fortran10's old school fortran iv/66 source code in a raspi ide debugger. clearly nothing like this will be possible for macro10, but for fortran10 it's worthwhile. + +onboard the raspi, insure that 'sudo apt install gcc' and 'sudo apt install gdb' are go. these cover the gfortran compiler, which does seem able to handle the source code. vscode and its 'modern fortran' extension also work. for vscode run configurations, see tasks.json and launch.json. + +here's the fortran10. note in the write (6, 10) the '6' is a 'unit designation' and the '10' is a format statement line number. currently unit designation for terminal is 6 on raspi but 5 on tops10. would like to make this portable, no differences between raspi and tops10. + + integer i + real x, y, x2, y2 + 10 format (2f10.5) + y = .00225 + x = sqrt(1. - y**2) + do 20 i=1,11 + write (6, 10) x, y + x2 = x**2 - y**2 + y2 = 2 * x * y + x = x2 + y = y2 + 20 continue + end + +with macro10, the 'print' of python and 'write' of fortran are the first topic. taking an accumulator containing a floating point number and printing it on the terminal in something like f10.5 format. the pdp10 has sixteen accumulators, and the numerical value contained in one of those is to be printed in 'human readable decimal form' on the terminal. + +before that, first step is to do the same but for an accumulator containing a fixed point twos complement binary number. the historical 'decimal output / decout' problem, as discussed in the 'early sixties' section of the levy book, and a kind of historical landmark, along with the contemporary topics of recursion, stack processing, algol, and the beginnings of academic computer science. + + a=1 + b=2 + p=17 + pdlen==40 + pdlist: block pdlen + opdef call [pushj p,] + opdef ret [popj p,] + crlf: byte (7)15,12 + start: reset + move p,[iowd pdlen,pdlist] + movei a,3 + call decout + hrroi a,crlf + outstr (a) + exit + decout: jumpge a,decot1 + push p,a + movei a,"-" + outchr a + pop p,a + movn a,a + decot1: idivi a,^d10 + push p,b + skipe a + call decot1 + pop p,a + addi a,"0" + outchr a + ret + end start