CARDIAC › Tips and tricks › Room
When it doesn't fit, split it
Say your program has two parts, and the second part needs what the first one worked out.
Normally you'd write one deck with both parts in memory at once.
cell contents notes
10 030 INP 30 cells 10-18: both parts in one deck: all of it in memory at once
11 130 CLA 30
12 230 ADD 30
13 631 STO 31
14 131 CLA 31
15 231 ADD 31
16 632 STO 32
17 532 OUT 32
18 900 HRS 00
30 000
31 000
32 000
Step through the natural way in Cardigan
When that doesn't fit, split it into two tapes. The first ends with HRS 02, the operator loads tape 2 and starts at 00, and the loader lays tape 2's code over tape 1's. Here's the nice part: every cell tape 2 doesn't load keeps its value, so tape 1's answer is still sitting there waiting. Only the bigger tape has to fit, and the room the code no longer needs goes to your data.
cell contents notes
10 030 INP 30 tape 1, cells 10-14: the first part: y = 2x, left in cell 31
11 130 CLA 30
12 230 ADD 30
13 631 STO 31
14 902 HRS 02 halt on 02: load tape 2
30 000
31 000
cell contents notes
10 131 CLA 31 tape 2, cells 10-14: its own code over tape 1's; y is still in cell 31, on no card of this tape
11 231 ADD 31
12 632 STO 32
13 532 OUT 32
14 900 HRS 00
32 000
Step through the CARDIAC way in Cardigan
Both print 84 for 21. In one deck the program needs 12 cells at once; split, the bigger tape needs 7.
A whole program split this way, step by step: programming with overlays.
From the tips in
cardiac-code on GitHub. All the tips.