The Execute Cycle - java.cms.livjm.ac.uk

advertisement
The Execute Cycle
Once the instruction has been “fetch”ed into the Current Instruction Register, the execute
cycle depends on the particular instruction in question;
LDA
n
Load the accumulator with the contents of memory location number n
1. Put n in Memory Address Register (MAR).
2. Get contents of memory location n into Memory Data Register (MDR).
3. Move contents of MDR into Accumulator (ACC).
SET
x
Set the accumulator to the absolute value x
1. Put x in ACC.
STA
n
Store the accumulator in memory location n
1. Put n in MAR.
2. Move contents of ACC into MDR.
3. Move MDR to location number n.
ADD
n
Add the contents of memory location n to the accumulator
1. Put n in Memory Address Register (MAR).
2. Get contents of memory location n into Memory Data Register (MDR).
3. Add contents of MDR into Accumulator (ACC).
SUB
n
Subtract the contents of memory location n from the accumulator.
Same as “ADD”, except last step is to subtract the contents of the MDR from ACC.
CMP
x
Compare ACC with the value x and set the flags register as follows :
Flags = 1 if ACC - x is positive ( i.e. 1,2 ... )
Flags = 0 if ACC - x is zero
Flags = -1 if ACC - x is negative
Execution has just one step – see above list.
JMP
l
go and execute the instruction labelled l
1. Move I to Programme Counter (PC).
JP
JE
JN
l
l
l
go and execute the instruction labelled l if Flags = 1
go and execute the instruction labelled l if Flags = 0
go and execute the instruction labelled l if Flags = -1
1. Move I to Programme Counter (PC), if Flags register has correct value.
Download