Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Notes on Sirius Autocode and this Emulator Sirius autocode is a direct descendant of the world's first programming language, the `autocode' developed by R.A. Brooker in 1953 for the Manchester Mark 1 computer. The Language and Emulator typing conventions Real `variables' are all called v, here the lower case letter. Integer variables or `indices' are called n. The vs form an array from v0 to, in the original Sirius, about v1000. The ns are numbered n0 ... n28 and are are not an array but individual scalar variables. The vs may be referred only by the following forms of subscripts: v1, v(101), vn1, v(n2), v(10+n1) So v(n1+10) was not allowed in the original language, although the emulator will in fact accept it. The RHS of an assignment may contain at most two terms and one operator. The latter are: + - / x Note the use of the lower case letter `x' for multiplication. The first term of an expression may be preceded by a unary minus. Real and integer variables may not be mixed in expressions. The functions implemented in the emulator so far are: SQRT, LOG (natural), EXP, EXPM (negative exponential), MOD (absolute value). They can appear only with a single argument. The forms acceptable are thus: v1 = -SQRT v2 v2 = EXPM v3 The only conditional operation is a jump to a numeric label. For the format of these see the example program. The jump symbol is here made up from `-' and `>' and may also be written without a condition. The emulator uses the typing conventions of Java for relational operators, i.e. ==, >=, != as well as ~ for the original `approximately equal to' (`=*')test which is true if the operands are equal to within the number of decimal places defined by the value of n0. (Sirius used BCD representation.) The original language had single symbols for all of these but did not have `<' which the emulator does accept. See the example program for the format of the PRINT instruction. Perhaps the frustrating part of writing the emulator was implementing the numeric format code. (In fact only the fixed point variant has been done so far.) I have therefore left it as an exercise for those interested to reverse engineer those! The TEXT instruction simply printed out everything that followed it up to a stretch of blank tape, here represented by the symbol `|'. There was an input instruction TAPE to read from a separate data tape. This has so far not been implemented. Notes on the Emulator Sirius autocode and its predecessors, Manchester and Pegasus autocodes, were implemented by interpreters. It was my original idea to write a low-level interpreter in JavaScript to run in a web browser. Since I couldn't make up my mind whether to try and implement this directly or to try and emulate something like the original hardware instruction set, this did not get beyond the conceptual stage. I then wrote a compiler in Fortran 90, the language with which I am probably nowadays most familiar, to translate into Fortran. This works, but requires a computer with a Fortran compiler. I then decided to rewrite the translator in JavaScript with JavaScript also as the target language. This provided a confirmation of the principle that it is not always possible to translate from a lower level langauge into a higher level. (I recall having been told that this is a consequence of Godel's Incompleteness Theorem...) Specifically, JavaScript does not have an arbitrary `goto' instruction. If you click the `Display Compiled Program' button after clicking `Compile' you will see the JavaScript instructions into which each autocode instruction is translated. These are stored in an array and executed one-by-one by a small interpreter. This also allows a single step facility. At present he interpreter will stop after 30,000 instruction have been performed, equivalent to about twelve minutes on the original Sirius.