214 Chapter 7 Low-Level Programming Languages sum. Oops, there is a necessary step not in the algorithm: We must clear the accumulator. We can either load sum into the accumulator first (to set it to zero) or we can load the first number into the accumulator rather than adding it in. Since we have made sure that sum is zero, let’s load it in first. So, after reading and adding three numbers, we must write out the sum. Oops, another missing step. We must store the accumulator into sum in order to write it out. Here is our completed program. Note that we had to have a statement that branches around the data values as the first statement. That is, execution begins with the instruction stored in location 0000. We have put the data at the beginning of the program rather than the instructions that operate on the data. Thus, we must have an instruction stored in location 0000 that puts the location of the first instruction in the program into the program counter. The ’" instruction does this. ’" , followed by
This is the end of the preview. Sign up
access the rest of the document.