-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18a9fca
commit 92b4882
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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](ipwr.py) | ||
|
||
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](../sec5-minimalist-walkthrough.md). 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](https://fortran-lang.org/) also work alright. for vscode run configurations, see [tasks.json](../../.vscode/tasks.json) and [launch.json](../../.vscode/launch.json). | ||
|
||
here's the [fortran10](ipwr.for). 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, exactly as discussed in the 'early sixties' section of the levy book. a historical curiosity, along with the contemporary hype around recursion, stack processing, algol, and 'academic computer science'. fortran was already old school, didn't have recursion, and mattered to 'lusers'. algol was the new school hype, had recursion, and mattered to academics and even 'european academics'. curious to contemplate which side history has been kinder to. | ||
|
||
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 |