temp=temp-1;
if temp>=0 goto loop;
end
(2), Assume in the RAM_DQ:
sum is stored at location A4,
temp is stored at location A3,
the contents of location A0 is 0,
the contents of location A1 is 1,
the contents of location A2 is 10010=6416.
We can translate the above C language program with the instructions listed in Table 1 into the
instruction program as shown in Table 2.
Table 2 Example of a program to sum from 1 to 100
Program with C Program with
instructions
Contents of RAM_DQ in HEX
Address Contents
sum=0;
LOAD A0 00 02A0
STORE A4 01 01A4
temp=100
LOAD A2 02 02A2
STORE A3 03 01A3
loop:sum=sum+temp;
LOOP:LOAD A4 04 02A4
ADD A3 05 03A3
STORE A4 06 01A4
temp=temp-1;
LOAD A3 07 02A3
SUB A1 08 04A1
STORE A3 09 01A3
if temp>0 goto loop; JMPGZ LOOP 0A 0504
end; HALT 0B 0C00
0C
… …
A0 0000
A1 0001
A2 0064
A3
A4
… …
III. Internal Registers and Memory
MAR (Memory Address Register)
MAR contains the memory location of the word to be read from the memory or written into the
memory. Here, READ operation is denoted as the CPU reads from memory, and WRITE operation