CSC 101 Summer 2010 Chapter 9 – Supplementary Example The ...
CSC 101 Summer 2010 Chapter 9 – Supplementary Example The ...
CSC 101 Summer 2010 Chapter 9 – Supplementary Example The ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>CSC</strong> <strong>101</strong><strong>Summer</strong> <strong>2010</strong><strong>Chapter</strong> 9 <strong>–</strong> <strong>Supplementary</strong> <strong>Example</strong><strong>The</strong> following example is intended to demonstrate how a short computer program works; how itis translated into the instruction codes for a particular hypothetical computer; and how it mightwork when executed in hardware.ASSUMPTION: <strong>The</strong>re are three locations in RAM, named Alpha, Beta, and Gamma, containingthree different numbers. <strong>The</strong>re is a fourth location in RAM named Temp that we can we use tohold values temporarily. <strong>The</strong> following “high-level” language program will put the three valuesin Alpha, Beta, and Gamma into increasing order. Here’s such a program written in a made-up“high-level” computer programming language:STEP PROGRAMMING STATEMENT0 if ( Beta
In the following page RAM[i] stands for the value at address i in RAM. <strong>The</strong> Program Counterwill start at 100 for this example.RAM0 12 (Corresponds to Alpha in high-level program)1 9 (Corresponds to Beta in high-level program)2 3 (Corresponds to Gamma in high-level program)3 0 (Corresponds to Temp in high-level program)…100 Load the value from RAM[1] into the ALU<strong>101</strong> Load the value from RAM[2] into the ALU102 If the first value is