Dinosaur
Joined 24 August 2022
→First Machine Code
Line 27:
==First Machine Code==
In 1970 at Auckland University, the Applied Mathematics class introduced the AMI computer, a decimal computer with a thousand five-digit words of storage, which one programmed in machine code only, thus learning about the bootstrap, the loader and the relocating loader. I still recall the bootstrap sequence, as its comprehension required the assimilation of novel ideas: on "power on", memory is cleared to zero and the instruction register holds 17000 - two digit operation code, three digit address. This is to read from the "paper tape" input (actually, a deck of punched cards) a five-digit sequence and place it at address zero. As the instruction address register is already zero, this code is then executed. The input is the three-number bootstrap sequence 17001 17002 12000, where
Once we had bootstrapped our comprehension to this higher level, the course moved on to the likes of writing
Later that year I wrote an interpreter for the AMI system in Fortran II for the IBM1620, and thereby won four milkshakes from a friend, Michael Dowling, who took the AMI course the following year and used my programme for test runs. On one of his assignments, he had difficulty and test runs were facilitated by the immediate feedback. Indeed, by flicking certain switches on the computer's console, trace output for each step could be elicited, hammered out at ten key whacks a second on the heavy-duty console typewriter, there being no lineprinter for this installation. I happened by, and the discussion went somewhat as follows:
Line 39:
"I suppose it won't work." "Yes it will!" - this time, double milkshakes.
Although the paper tape reader only accepted five-character numbers as input there was a dispensation: rather than typing out the code of the bootstrap, ''etc.'' every time, we could instead put BOOT or LOAD or ASSEM that would be recognised by the interpreter's input processor to save us the trouble. My interpreter went a little further. First it read special input presenting these names and their replacement, and it also allowed additional names to be described, such as FACT, which computed factorial numbers recursively - for 1971 the AMI computer had been converted to working with a stack for entry and return. Since the interpreter's processor for the READ opcode knew the address at which the datum being read was to be placed, it therefore knew where the first word of the FACT routine was being placed. Subsequent appearances of FACT in the input (such as in the expansion of FACT) were converted to a single word, the ENTER opcode with that address. Interpreters can reach across levels of interpretation for special effects!
Later on, I modified my interpreter to replace the Fortran code that loaded and decoded the opcode by certain nonsense statements, then, once the compiler had produced the machine code card deck, replaced the card bearing the rubbish code with one containing choice IBM1620 machine code operations (of just the same size) that performed those critical steps much faster. The payoff was an advance from about five to fifteen AMI operations a second. A fellow the year ahead of me had done likewise, and his interpreter ran at thirty steps a second. Thus began early a relaxed attitude to code twiddling and disdain for those who would prevent it. Despite all these interpreters, I still couldn't work out how Fortran compiled FORMAT statements, especially since different WRITE statements might use the same FORMAT statement. Was each WRITE statement compiled with reference to its named FORMAT statement? Surely that would be very messy...▼
Once my interpreter was working reliably, attention turned to issues of speed. An early improvement involved removing excessive testing. Because the only IF-statement form was the three-way IF-test (and this ever since has provoked me to consider at least briefly the possibility of unexpected values, such as negative when only zero or positive were expected) it was often the case that one IF-test was followed by another for which some of the possibilities had been precluded by the earlier tests. Ah, but what if there was some mistake? Surely this should be checked, since it was a further option of an already-needed test? In the event, no such test ever was triggered and I decided to remove them, resulting in less code, fewer error messages, and somewhat speedier execution. However, computer arithmetic can deviate from mathematics, and adding some positive value may not in fact produce a more positive result. With the IBM1620's signed arithmetic the results are not as dramatic as with two's complement arithmetic but there are still opportunities, and alas, the modernisers have discarded the IF OVERFLOW and similar tests. It is best if the arithmetic in use is certain to not provoke overflows, and then they need not be tested for...
During this period the console typewriter flung the slug for the letter W from its key and we had to adjust our programmes to use VV instead, much to the amusement of Gary Tee who noted that we were reversing a millenium-old development in orthography.▼
▲
Over the Christmas holidays I gained money instead of milkshakes: employed by the computer centre to write a data-checking system in Fortran IV, plus my first introduction to IBM1130 assembler. I now was quite clear on the distinction between source code (as in COBOL) and compiled code.▼
Despite all these interpreters, I still couldn't work out how Fortran compiled FORMAT statements, especially since different WRITE statements might use the same FORMAT statement. Was each WRITE statement compiled with reference to its named FORMAT statement? Surely that would be very messy...
▲During this period the console typewriter flung the slug for the letter W from its key and we had to adjust our programmes to use VV instead, much to the amusement of our lecturer Gary Tee who noted that we were reversing a millenium-old development in orthography.
▲Over the Christmas and summer holidays I gained money instead of milkshakes: employed by the computer centre to write a data-checking system in Fortran IV, plus my first introduction to IBM1130 assembler. I now was quite clear on the distinction between source code (as in COBOL) and compiled code.
==Metastasis==
|