52 lines
2 KiB
Text
52 lines
2 KiB
Text
[Loop-and-a-half for Rosetta Code.
|
|
EDSAC program, Initial Orders 2.]
|
|
T64K [load at location 64 (arbitrary choice)]
|
|
GK [set @ (theta) parameter]
|
|
[Constants]
|
|
[0] OF [digit 9]
|
|
[1] JF [to inc digit after subtracting 9]
|
|
[2] #F [figures mode]
|
|
[3] !F [space]
|
|
[4] NF [comma (in figures mode)]
|
|
[5] @F [carriage return]
|
|
[6] &F [line feed]
|
|
[Variable]
|
|
[7] PF [current digit]
|
|
|
|
[First subroutine to print digits 0..9]
|
|
[8] A3F T20@ [plant return link as usual]
|
|
T7@ [digit := 0]
|
|
[11] O7@ [loop: print digit]
|
|
A7@ S@ [is digit 9?]
|
|
E20@ [if so, jump to exit]
|
|
O4@ O3@ [print comma and space]
|
|
A1@ [inc digit in acc]
|
|
T7@ [update digit in store]
|
|
E11@ [always loop back]
|
|
[20] ZF [(planted) return to caller with acc = 0]
|
|
|
|
[Second subroutine to print digits 0..9
|
|
Instead of saying "print a comma after each digit except the last"
|
|
it says "print a comma before each digit except the first".]
|
|
[21] A3F T33@ [plant return link as usual]
|
|
T7@ [digit := 0]
|
|
E29@ [jump into middle of loop]
|
|
[25] A1@ [loop: inc digit in acc]
|
|
T7@ [update digit in store]
|
|
O4@ O3@ [print comma and space]
|
|
[29] O7@ [print digit]
|
|
A7@ S@ [is digit 9?]
|
|
G25@ [if not, loop back]
|
|
[33] ZF [(planted) return to caller with acc = 0]
|
|
|
|
[Enter with acc = 0]
|
|
[34] O2@ [set teleprinter to figures]
|
|
A35@ G8@ [call first subroutine]
|
|
O5@ O6@ [print CR, LF]
|
|
A39@ G21@ [call second subroutine]
|
|
O5@ O6@ [print CR, LF]
|
|
O2@ [print dummy character to flush teleprinter buffer]
|
|
ZF [stop]
|
|
E34Z [define entry point]
|
|
PF [value of acc on entry (here = 0)]
|
|
[end]
|