Name: Student ID:
Question 1 (15 Marks) Answer the following questions: a) What is a stack? b) What is the purpose of the stack pointer? c) What type of instruction is used to retrieve data from the stack? d) What addressing modes can the JMP instruction use? e) How is the stack pointer affected by the JSR instruction? f) What is a nested subroutine? g) What are the two methods by which microprocessors handle I/O operations? h) Write a program segment that will: read in data from the switch bank in address $1500 and double the number and display the result on the LED bank in address $1600.
Question 2 (5 Marks) Consider the following program segment LDAA #$05 LDAB #$04 INCB SBA WAI After executing the program, the condition code register flags (N,V,Z,C) will be: N V Z C
1
Question 3 (10 Marks) Consider the following program segment: LDX #$2000 LDAA 00, X LDAB 01, X ABA CMPA #$0A BEQ LABEL1 LDAA #$FF STAA $2005 BRA END LABEL1: LDAA #$BA STAA $2005 WAI
END:
Assuming we have 2000 2001 $04 $06
After running the above program segment, what is the content of memory location $2005? Question 4 (10 Marks) Consider the following program segment. LDS #$2000 LDX #$2200 LDAB #6 LDAA 00, X PSHA INX DECB BNE LOOP1 LDX #$2300 LDAB #6 PULA ASLA STAA 00,X INX DECB BNE LOOP2 SWI
LOOP1:
LOOP2:
2
If the contents of address $2200, $2201, $2202, … , $2206 are as follows: 2200 2201 2202 2203 2204 2205 2206 $01 $02 $03 $04 $05 $06 $07
What would be the contents of address of $2300, $2301, …, $2306
2300 2301 2302 2303 2304 2305
? ? ? ? ? ?
Question 5 (10 Marks) Consider the following program segment: ORG LDS START LDAA LDAB STAA JSR ABA STAA STAB WAI SUB1 PSHA PSHB PULA PULB ADDA $1040 RTS #$08 #$05 $1040 SUB1 $2100 $2101 $4000 #$3FFF
3
After running the above program, what is the content of memory location $2100 and $2101? Completely explain your answer!
Question 6 (5 Marks)