Docsity

3 Question for Quiz 2 - Microprocessors | ECE 332, Quizzes of Microprocessors

Toggle sidebar
bg1
1 of 1
Boise State University
Department of Electrical and Computer Engineering
ECE 332 Microprocessors
Quiz 2 โ€“ September 19, 2007
Name: ______________________________
1. What is saved to which register when your main program calls a subroutine? Why the save is required?
The return address (pc+4) is saved to r31 (or ra).
2. Write a short code segment to swap the content of two memory locations.
Assuming that VALUES contains the memory address of two 32-bit values
movia r5,VALUES
#get the values
ldw r6,0(r5)
ldw r7,4(r5)
#restore them
stw r7,0(r5)
stw r6,4(r5)
3. How do you access LEDs and Switches?
movia r5, LED_ADDRESS
movi r6,0x8 #write eight to LED
stwio r6,0(r5)
movia r7,SWITCHES_ADDRESS
ldwio r8,0(r7)

Partial preview of the text

Download 3 Question for Quiz 2 - Microprocessors | ECE 332 and more Quizzes Microprocessors in PDF only on Docsity!

1 of 1

Boise State University Department of Electrical and Computer Engineering ECE 332 Microprocessors Quiz 2 โ€“ September 19, 2007

Name: ______________________________

  1. What is saved to which register when your main program calls a subroutine? Why the save is required?

The return address (pc+4) is saved to r31 (or ra).

  1. Write a short code segment to swap the content of two memory locations.

Assuming that VALUES contains the memory address of two 32-bit values

movia r5,VALUES #get the values ldw r6,0(r5) ldw r7,4(r5) #restore them stw r7,0(r5) stw r6,4(r5)

  1. How do you access LEDs and Switches?

movia r5, LED_ADDRESS movi r6,0x8 #write eight to LED stwio r6,0(r5)

movia r7,SWITCHES_ADDRESS ldwio r8,0(r7)