I wanted to review the code I had written. When I started this project I was a complete noob to both the PDP-1 machine and assembly language. After about a month's effort I felt that I was beginning to "get it".
So I went back and reviewed an early piece of code, drawing the LEM, and sure enough there were a number of improvements to be had.
/ Draw the LEM based on an 18-bit by 18 word bitmap.
OLD NEW
=== ===
lac (400000
dac bit
lac bsx
dac tmp
lbn, lac . lbn, lac .
sza i sza i
jmp lt1 jmp lt1
dac bmr dac bmr [-20]
lac (400000
dac bit
nb0, lac bit nb0, lac bit [0]
and bmr and bmr
sza i sza i
jmp nb1 jmp nb1
lac bsx lac bsx
lio bsy lio bsy
dpy-i 4700 dpy-i 4700
nb1, lac bit nb1, lac bit [-10]
sad (1 rar 1s
jmp nrw dac bit
sad (400000
lac bit jmp nrw
rar 1s
dac bit
lac bsx lac bsx
add scl add scl
dac bsx dac bsx
jmp nb0 jmp nb0
nrw, lac lbn nrw, idx lbn [-50]
add (1
dac lbn
lac bsy lac bsy
sub scl sub scl
dac bsy dac bsy
lac scx lac tmp
sub (4400 dac bsx
dac bsx
jmp lbn
lac (400000
dac bit
jmp lbn
I'm not going to go into detail on the code above. Suffice it to say that I'm pretty happy with the improvements. The important thing is the numbers off to the right. They represent the number of microseconds I was able to eliminate from the OLD code when creating the NEW. Both of course do exactly the same thing.
PDP-1 instruction have the following performance characteristics:
- Memory Cycle Time: The fundamental memory cycle time of the PDP-1 is 5 microseconds.
- Instruction Speed: The jmp instruction, along with other single-cycle instructions, requires only one memory reference and completes within that 5-microsecond cycle.
- Indirect Addressing: If a jmp instruction uses indirect addressing (indicated by a 1 in the defer bit), it requires an additional 5 microseconds for each level of redirection.
- Comparison: Unlike jmp, two-cycle instructions (such as add, sub, deposit, or load) take 10 microseconds to complete.
In the above code comparison the numbers on the right indicate the how many "microseconds" were removed from that block of the code (demarked by the labels). Another thing to consider is how any times that block of code will be executed when drawing the LEM. The lbn and nrw blocks only execute once per row of the bitmap, while the nb1 code executes once per pixel. So the total savings for optimizing this code is:
(20 + 50) x 18 rows = 1,260 microseconds
10 x 18 columns x 18 rows = 3,240 microseconds
==================
4,500 microseconds
4.5 ms every time the LEM is drawn which is about 10 times per second. That doesn't sound like much but it leaves more time to draw the other pixels and thus reduce flicker (say).
Michael Gardi
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.