Count in octal: Difference between revisions

Added solution for EDSAC.
(Added solution for EDSAC.)
Line 1,261:
WriteLn(DecToOct(i));
end.</lang>
 
=={{header|EDSAC order code}}==
Uses 17-bit integers, maximum 2^16 - 1 (177777 octal). It would take the original EDSAC 18 or 19 hours to exhaust these, so there is not much point in extending to 35-bit integers.
<lang edsac>
[Count in octal, for Rosetta Code.
EDSAC program, Initial Orders 2.]
 
[Subroutine to print 17-bit non-negative integer in octal,
with suppression of leading zeros.
Input: 0F = number (not preserved)
Workspace: 0D, 4F, 5F]
T64K GK [load at location 64]
A3F T28@ [plant return link as usual]
T4D [clear whole of 4D including sandwich bit]
A2F [load 0...010 binary (permanently in 2F)]
T4F [(1) marker bit (2) flag to test for leading 0]
AF [load number]
R2F [shift 3 right]
A4D [add marker bit]
TD [store number and marker in 0D]
H29@ [mask to isolate 3-bit octal digit]
[Loop to print digits]
[10] T5F [clear acc]
C1F [top 5 bits of acc = octal digit]
U5F [to 5F for printing]
S4F [subtract flag to test for leading 0]
G18@ [skip printing if so]
O5F [print digit]
T5F [clear acc]
T4F [flag = 0, so future 0's are not skipped]
[18] T5F [clear acc]
AD [load number + marker bit, as shifted]
L2F [shift left 3 more]
TD [store back]
AF [has marker reached sign bit yet?]
E10@ [loop back if not]
[Last digit separately, in case input = 0]
T5F [clear acc]
C1F T5F O5F
[28] ZF [(planted) jump back to caller]
[29] UF [mask, 001110...0 binary]
 
[Main routine]
T96K GK [load at location 96]
[Constants]
[0] PD [1]
[1] #F [set figures mode]
[2] @F [carriage return]
[3] &F [line feed]
[4] K4096F [null char]
[Variable]
[5] PF [number to be printed]
[Enter with acc = 0]
[6] O1@ [set teleprinter to figures]
[7] U5@ [update number, initially 0]
TF [also to 0F for printing]
[9] A9@ G64F [call print soubroutine]
O2@ O3@ [print CR, LF]
A5@ A@ [load number, add 1]
E7@ [loop until number overflows and becomes negative]
O4@ [done; print null to flush teleprinter buffer]
ZF [halt the machine]
E6Z [define entry point]
PF [acc = 0 on entry]
[end]
</lang>
{{out}}
<pre>
0
1
2
3
4
5
6
7
10
[...]
177775
177776
177777
</pre>
 
=={{header|Elixir}}==
113

edits