Using a Trace Table on a Low Level Program

cpu-chipIn the following set of challenges, we will use a trace table to demonstrate the impact of the FDE cycle on the main registers:

  • Program Counter (PC)
  • Memory Address Register (MAR)
  • Memory Data Register (MDR)
  • Current Instruction Register (CIR)
  • Accumulator (ACC)

Note that the following program are all based on the LMC language and are hence based on direct addressing.

To complete this task, you need to understand what happens inside the CPU at each stage of the FDE cycles. For instance:

  • A the start of the Fetch stage of the FDE cycle, the PC contains the address of the next instruction to be Fetched. So the value of the PC is copied to the MAR so that the instruction can be retrieved from memory. The instruction stored at this MAR address will be stored in the MDR and immediately copied to the CIR.
  • The PC is then automatically incremented by 1.
  • What happens during the Execute stage of the FDE cycle will depend on the instruction itself.
  • It may be that more data may be loaded from memory using the MAR and MDR (e.g. LDA, ADD, SUB instructions).
  • It may be that the PC will be overridden by a BRP, BRZ or BRA instruction.
  • The Accumulator may also be overwritten by an input value (INP), the result of executing a calculation (ADD, SUB) or of loading data from memory (LDA).
Challenge #1Challenge #2Challenge #3

Challenge #1:


When tracing the following algorithm we will use the following input values:

  • First input: 5
  • Second input: 4

Trace Table


We have started to complete the trace table for the first two FDE cycles of this program. Your task is to complete this trace table for the whole program.
 FDE StagePCMARMDRCIRACCOutput?
– RESET –00000
Fetch10INPINP0
Execute10INPINP5
Fetch21STA 99STA 995
Execute2995STA 995

Challenge #2:


When tracing the following algorithm we will use the following input values:

  • First input: 5
  • Second input: 4

Trace Table


We have started to complete the trace table for the first two FDE cycles of this program. Your task is to complete this trace table for the whole program.
 FDE StagePCMARMDRCIRACCOutput?
– RESET –00000
Fetch10INPINP0
Execute10INPINP5
Fetch21STA 99STA 995
Execute2995STA 995

Challenge #3:


When tracing the following algorithm we will use the following input value:

  • First input: 3

Trace Table


We have started to complete the trace table for the first two FDE cycles of this program. Your task is to complete this trace table for the whole program.
 FDE StagePCMARMDRCIRACCOutput?
– RESET –00000
Fetch10INPINP0
Execute10INPINP3
Fetch21STA 99STA 993
Execute2993STA 993

Share Button
Tagged with: