Array Copy
This program makes use of the auto-index registers at memory locations 10 and 11 to copy an array from one location to another. Location 10 (labelled as pArr1), references the array arr1 (the original). Location 11 (pArr1), references arr2 (the copy). Since the auto-index registers increment before being used, pArr1 and pArr2 are initialised to arr1-1 and arr2-1. Thus, when the first iteration of the loop executes, pArr1 and pArr2 will be correctly set to arr1 and arr2.
/ array copy:
*0200
cla cll
/ copy arr1 to arr2
copy,tad i pArr1
dca i pArr2
isz count
jmp copy
/ done
hlt
/ data
count, 7772
/ auto-indexing
*10
pArr1, arr1-1
pArr2, arr2-1
/ the arrays
*220
arr1, 1111;2222;3333;4444;5555
*240
arr2,0;0;0;0;0
PDP-8, PDP-8/A, PDP-8/E, PDP-8/F, PDP-8/I, PDP-8/L, PDP-8/M, PDP-8/S, PDP-11, PDP-12, and others in the Krten Collection
This program blinks the AC and MQ lights.
loop, 0000 2020 isz delay / create a delay
0001 5000 jmp loop
0002 7200 cla / clear AC so we can load it
0003 1021 tad value / get value
0004 7421 mql / stash AC into MQ
0005 1021 tad value / fetch value again
0006 7040 cma / complement AC
0007 2021 isz value / get to next value
0010 7000 nop / ignore possible "skip" from ISZ
0011 5000 jmp loop / and do it all again
delay, 0020
value, 0021