The Jump specification

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

The Jump specification

AndyGeo
I don't get this 100%...

@END
D;JEQ

 I know the A register is set to the address of where to jump if a jump is made.

So further down the code it goes to the next line such as:

@END?

Also in figure 4.2 the A register is set to @LOOP and 0;JMP.

I guess this is stating the end of a loop and instruct it to run to the test but I can't see how this is working.

Reply | Threaded
Open this post in threaded view
|

Re: The Jump specification

cadet1620
Administrator
AndyGeo wrote
I don't get this 100%...

@END
D;JEQ

 I know the A register is set to the address of where to jump if a jump is made.

So further down the code it goes to the next line such as:

@END?
Correct, when the D value matches the jump condition, the next instruction executed will be the instruction at the address in A, which in this case is the @END after the (END) label.
Also in figure 4.2 the A register is set to @LOOP and 0;JMP.

I guess this is stating the end of a loop and instruct it to run to the test but I can't see how this is working.
        @LOOP
        0;JMP
always jumps to (LOOP) so the loop adds the next value.

    (END)
        @END
        0;JMP
is an "infinite loop" -- a loop that never terminates -- that keeps the computer from running wild after the program completes.

The test script doesn't just run after your program ends. It actually starts before your program. It is responsible for loading your program and controlling the number of instructions the computer runs during the test, as well as checking your program's results.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: The Jump specification

AndyGeo
Thanks again Mark. I slipped up with the syntax but after a while it became more intuitive. Initially i thought the parens weren't doing anything, so need to make sure to read the book properly!

I just managed to complete both mult and fill assignments. It doesn't look pretty but it works!