; PBlazIDE Homework #1 ("Add all and subtract all" program) ; By Rory Johnson start: LOAD s0, 0 ; Number #1 to be added LOAD s1, 0 ; Number #2 to be added addall: ; Outer add loop: CALL addloop ; Add to all possible numbers the current value of Number #1... ADD s0, 1 ; ...then increment Number #1. COMP s0, 0 ; See if Number #1 has already had the values of all eight-bit hex values and looped back to zero JUMP NZ, addall ; If not, repeat JUMP suball ; If so, start subtracting numbers addloop: ; Inner add loop: LOAD s3, s0 ; Add first number ADD s3, s1 ; Add second number and compute the result STORE s3, 0 ; This location does something to the result and can be changed ADD s1, 1 ; Increment Number #2 COMP s1, 0 ; See if Number #2 has had the value of all possible 8-bit hex values JUMP NZ, addloop ; If not, repeat RET ; If so, jump back to the outer loop, increment Number #1 by one, then suball: ; Outer subtract loop: CALL subloop ; Subtract the current value of Number #1 from all possible numbers... ADD s0, 1 ; ...then increment Number #1. COMP s0, 0 ; See if Number #1 has already had the values of all eight-bit hex JUMP NZ, suball ; If not, repeat CALL fin ; If so, jump to end subloop: ; Inner subtract loop: LOAD s3, s0 ; Add first number SUB s3, s1 ; Add second number and compute the result STORE s3, 0 ; Again does something to the result, again can be changed ADD s1, 1 ; Increment second number by one COMP s1, 0 ; See if Number #2 has had all eight-bit hex values JUMP NZ, subloop ; If not, repeat RET ; If so, jump back to the outer loop and increment Number #1 by one fin: JUMP fin ; Loop endlessly. The rest of the real program would be executing now.