Computer Systems Architecture Homework/Lab
Lab 3 –MIPS Assembly language
Programming with MARS IDE Array
The purpose of this lab is to introduce you to the layout and structure of the Mars IDE development tool in addition to Array programming. In this lab, Data section will be used in the MIPS Assembly language to represent the array elements.
Procedure:
I. Follow the same procedure in Lab1.
II. From the main menu, choose “File” “New”
III. You will find a blank file. Start typing your program code instructions as shown in the screen shot below.
The code:
( # ---------------------------- Lab 3------------------------------------- #-----------------------Array -------------MIN and MAX---------- #-------------------------By: Dr. Abdallah--------------------------- #--------------------------- ------------------------------ .text . globl __start __start: la $t0,array # $t0 will point to elements lw $t1,count # exit loop when $t1 is 0 lw $t2,($t0) # initialize both min ($t2) lw $t3,($t0) # and max ($t3) to a[0] add $t0,$t0,4 # pointer to start at a[1] add $t1,$t1,-1 # and go round count-1 times loop : lw $t4,($t0) # load next word from array bge $t4,$t2,notMin # skip if a[ i ] >= min move $t2,$t4 # copy a[ i ] to min notMin : ble $t4,$t3,notMax # skip if a[ i ] <= max move $t3,$t4 # copy a[ i ] to max notMax : add $t1,$t1,-1 # decrement counter add $t0,$t0,4 # increment pointer by word bnez $t1,loop # and continue if counter>0 ################################################# # # # data segment # # # ################################################# .data array : .word 3,4,2,6,12,7,18,26,2,14,19,7,8,12,13 count : .word 15 ## ## end of file )
IV. Click on the icon “Assemble the current file”
V. Run the program as shown below
Figure 1
· Observe the registers/Memory locations values after each Step Run. Record the final values.
Questions:
1- What is the final value of $t2?
2- What is the final value of $t3?
3- What does the value of $t2 represent?
4- What are Min and the Max numbers in the array?
5- Modify this program to find the Min. value only.
Things to turn in as your Lab 3 Report, attached in this order:
1- Your name, Course Number, Lab Number and Date
2- Screen shot of the Program
3- Results/Observations such as the final screen shot of the registers and memory locations
4- Questions with answers
6- References if any