Docsity

Quiz Solution for CPEG 222 - Microprocessor Based Systems, Spring 2005, Quizzes of Microprocessors

Toggle sidebar
bg1
CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name: SOLUTION
Spring 2005 - Jorge Andres Garcia - Quiz 2
1. (10 pts) In your own words, different from commenting the lines of code, tell me what the following code does, what
purpose it serves.
Use the area at the bottom of the page if you want to follow the instruction execution to gain insight into the code
This bit of code executes infinitely. This is because H:X is never modified after being set to 0x1000 and will never equal 0.
The bne will always be taken.
2. (10 pts) Comment the code. Only useful comments are welcome. An explanation has been provided for the instruction
AIX given we did not cover it in class.
label1: pshh
pshx ; push H:X onto the stack
ldhx #$1000 ; Load 0x1000 into H:X
label2: deca ; A = A - 1
cphx #$0000 ; Compare H:X to 0
bne label2 ; branch if not equal to label2
pulx
pulh ; pull H:X off the stack
rts ; return from sub-routine

Partial preview of the text

Download Quiz Solution for CPEG 222 - Microprocessor Based Systems, Spring 2005 and more Quizzes Microprocessors in PDF only on Docsity!

CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name: SOLUTION

Spring 2005 - Jorge Andres Garcia - Quiz 2

1. (10 pts) In your own words, different from commenting the lines of code, tell me what the following code does, what

purpose it serves.

Use the area at the bottom of the page if you want to follow the instruction execution to gain insight into the code

This bit of code executes infinitely. This is because H:X is never modified after being set to 0x1000 and will never equal 0.

The bne will always be taken.

2. (10 pts) Comment the code. Only useful comments are welcome. An explanation has been provided for the instruction

AIX given we did not cover it in class.

label1: pshh pshx ; push H:X onto the stack ldhx #$1000 ; Load 0x1000 into H:X label2: deca ; A = A - 1 cphx #$0000 ; Compare H:X to 0 bne label2 ; branch if not equal to label pulx pulh ; pull H:X off the stack rts ; return from sub-routine