CSC270 Homework 7
This assignment is due at the beginning of Lab #8
Problem #1: Assembly
Assemble the following program by hand:
ORG 0020
alpha FCB 11
beta FCB 2
gamma FCB 3
delta FCB 21
result FCB 0
ORG 0000
start: ldx #alpha
ldaa 0,X
adda 1,X
adda 3,X
adda 2,X
lsra
lsra
staa 4,X
jmp start
When you assemble your program, show the hexadecimal bytes of the opcodes on the left of each instruction, as we did in class.
Add comments to indicate what the program does in each step, and what the number stored in the variable result represents in terms of the other four.
How many cycles does the program take to execute one loop?
Show the contents of the memory once your program is loaded into it.
Problem #2: Performance Analysis
Rewrite the program above using direct mode instead of indexed mode. Count the number of bytes of code of this new program and compare it to the number of bytes taken by the original program. Comment on the difference.
Count the number of cycles taken by your program to execute one loop and compare it to that of the original program. Comment on the difference.
Problem #3: Performance Analysis Revisited
Same questions as for Problem #2, but use extended mode instead of direct mode.