Hello world/Line printer: Difference between revisions
Content added Content deleted
(Added alternative solution for EDSAC.) |
m (Small change to code in alternative EDSAC version) |
||
Line 429: | Line 429: | ||
The EDSAC PC simulator allows .F for null and *F for letter shift, but it seems from WWG that on the original EDSAC these had to be input as K4096F and K2048F respectively. |
The EDSAC PC simulator allows .F for null and *F for letter shift, but it seems from WWG that on the original EDSAC these had to be input as K4096F and K2048F respectively. |
||
<lang edsac> |
<lang edsac> |
||
[Alternative "Hello World" for Rosetta Code |
[Alternative "Hello World" for Rosetta Code] |
||
EDSAC, Initial Orders 2.] |
|||
[Subroutine to print a string. |
[Subroutine to print a string.] |
||
[Parameter: A order for first character follows subroutine call (G order).] |
|||
[Modified 2022-07-13: A order for first character was formerly passed in 0F.] |
|||
[String is terminated with EDSAC null, which is printed] |
|||
T64K GK [load at 64, set base of relative addresses] |
|||
T56K GK [load at 56; set relative addressing] |
|||
A18@ U17@ [plant return link, increasing address by 3 |
|||
instead of 2 as usual] |
|||
S19@ [make A order to load A order after subroutine call] |
|||
T4@ [plant in code] |
|||
[4] AF [(planted) load A order after subroutine call] |
|||
[5] T6@ [loop: plant A order for next character] |
|||
[6] AF [load next character] |
|||
UF [to 0F for printing; keep it in acc] |
|||
OF [output to teleprinter] |
|||
E12@ [if char >= 0, not EDSAC null] |
|||
A20@ [if char < 0, add 15 to test for EDSAC null] |
|||
G16@ [jump to exit if null] |
|||
[ |
[12] TF [clear acc] |
||
A6@ A2F [inc address in A order above] |
|||
G5@ [loop back, because top 5 bits = A = 11100] |
|||
[(*) The accumulator contains an A order, so its top 5 bits are the code |
|||
[16] TF [clear acc on exit (EDSAC convention)] |
|||
for A, i.e. 11100. Hence the accumulator is negative, and G causes a jump.] |
|||
[17] ZF [(planted) jump back to caller] |
|||
[18] U3F [constant for making return link] |
|||
[19] U1F [constant for picking up parameter] |
|||
[20] K2048F [constant for testing final null] |
|||
[Main routine] |
[Main routine] |
||
T96K GK [load at 96 |
T96K GK [load at 96; set relative addressing |
||
[Enter with acc = 0] |
|||
[0] |
[0] A@ G56F [call print subroutine] |
||
A4@ [A order for first character of string] |
|||
ZF [subroutine returns here; halt machine] |
|||
[4] K2048F HF EF LF LF OF !F WF OF RF LF DF @F &F K4096F |
|||
[The above string is: letter shift, 'HELLO WORLD', CR, LF, null] |
|||
[5] A6@ [A order first character of string] |
|||
EZ [define entry point] |
|||
PF [acc = 0 on entry] |
|||
EZ [define entry point] |
|||
PF [acc = 0 on entry] |
|||
[end] |
[end] |
||
</lang> |
</lang> |