Confused about CPU-external.cmp

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Confused about CPU-external.cmp


So I was working through CPU-external.cmp by hand so I could compare what I was getting from my own CPU to what I should be getting. I was going through the assembly language provided in the comments of the file, but I found something that did not make sense.

Following line 12 of the assembly, I believe that the CPU should jump to line 14(I expected the D-register to equal -1 at time when the JLT command is given). Thus, the CPU should skip line 13(@999). However in the compare file, the CPU clearly accepts @999 as you can see that ‘addressM’ is set to 999 at time 13. At the same time in the compare file, the PC jumps from 11 to 14. How can the CPU jump from 11 to 14 while taking the command from line 13?

I have copied the assembly from the comments of the CMP file and pasted them below. I have also added line numbers.

1 @12345
2 D=A
3 @23456
4 D=A-D
5 @1000
6 M=D
7 @1001
8 MD=D-1
9 @1000
10 D=D-M
11 @14
12 D;JLT
13 @999
14 A=A+1
Reply | Threaded
Open this post in threaded view

Re: Confused about CPU-external.cmp

You should be looking at CPU.tst/.cmp so that you can see the current D register values. The -external tests are for people who are not using DRegister in their CPU.

Test setups are strange. Because there is no RAM or ROM involved, each individual instruction test sets input values for 'instruction' and 'inM'. The PC does not affect the sequence of instructions fed to the CPU by the test, nor does the A register affect what the inM value is.