# Using a Trace Table on a Low Level Program

In 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 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
1. INP
2. STA 99
3. INP
5. OUT

#### 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
1. INP
2. STA 99
3. INP
4. STA 98
5. SUB 99
6. BRP 08
7. LDA 99
8. BRA 09
9. LDA 98
10. OUT

#### 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
1. INP
2. STA 99
3. LDA 99
4. SUB one
5. STA 99
6. OUT
7. BRP 3
8. HLT
9. one DAT 1

#### 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

Did you like this challenge?

Click on a star to rate it!

Average rating 2.5 / 5. Vote count: 82

No votes so far! Be the first to rate this post.

As you found this challenge interesting...