|
Correct. I'm still thinking there's an issue with this code/pseudocode.
Pseudocode:
-----------
// Program: PointerDemo
// Starting at base address R0,
// sets the first R1 words to -1
n = 0
LOOP:
if (n == R1) goto END
*(R0 + n) = -1
n = n + 1
goto LOOP
END:
-----------
"Starting at base address R0, sets the first R1 words to -1."
I place the value 10 in R1 and then run the program.
The second time through the loop, R1's value is now -1.
There is now no end to the loop as R1 will never be 10.
My corrected version:
Pseudocode:
-----------
// Program: PointerDemo
// Starting at base address R1,
// sets the first R0 words to -1
n = 0
LOOP:
if (n == R0) goto END
*(R1 + n) = -1
n = n + 1
goto LOOP
END:
-----------
I could place the value 10 in R0 and things would work fine.
Am I correct? If not, what am I missing?
|