FIRST Robotic Competition - Program Execution

Lets store that program at location 100 and execute it. Note that the opcodes I show would actually be numbers. For simplicity I will show them as nmemonics instead. Our program in main memory looks like this:

           MVI 1,R0		; prod = 1
           MVI 2,R2		; index=2
    Loop1:
           ADD R0,R2		; prod + index
           MOV ACC,R0		; prod =
           DCR R2		; index-1
           MOV ACC,R2		; index =
           JNZ Loop1		; for()
  
Address Data
100 MVI R0
101 1
102 MVI R2
103 2
104 [Loop1] ADD R0,R2
105 MOV ACC,R0
106 DCR R2
107 MOV ACC,R2
108 JNZ
109 104 [Loop1]

To execute this code we start with the PC set to 100.

The result of this loop, prod, is stored in R0. It was computed the second time thru location 105. That value is 4.


Last modified 11 Dec 2006
http://brown.armoredpenguin.com/~abrown/contact.html
http://brown.armoredpenguin.com/~abrown/first/training/ComputerBasics/execution.html