Day 24
I. Last Time:
A. Misc. MIPS Floating Point Stuff
Data Loading/Moving:
lwc1 - Load word to c1
swc1 - Store word from c1
Only diff is that rs field specifies a f register.
Movement from R-regs to Co-Pro regs:
Misc. Others:
mfc1.TYPE - Move From Co-Pro 1 to R reg
TYPE is s=single pred, d=double prec
mtc1.TYPE - Move to Co-Pro 1 from R reg
abs.TYPE - Compute Absolute Value
cvt.ETYPE.ETYPE
ETYPE is w=integer, s=single pred, d=double prec
Works only with float regs.
(Special "Inf" Boundary value if out of range for float,
0 if out of range for ints)
mov.TYPE - Move data from one reg to another.
neg.TYPE - Negate a value
B. Problems w/ Functions (to this point):
1. More than 4 args?
2. Args Bigger than 32-bits?
3. Large Return Values?
C. Large Parameters and Lareg Return Values
What if you want to pass more than 128 bits?
What if you want to return more than 64 bits?
II. New Stuff:
Summary/Things We've learned:
Large Static Initializations are done with a "copy" loop
at the begining of the function where they aer declared.
Compilers play some funny tricks to optimize copying data.
These same tricks typically are specific to a single
implementation of the ISA.
Compilers will sometimes add in what looks like unndeeded
branches, but these may really be harmless.
Passing (large data) by value is much less efficient than
passing by reference because the entire object must be copied.
Compilers use pointers to help deal with return values.
The return value is written into the caller's stack space
and then copied (by the caller) into it's final destination.
Saving space for a0-a3 in the caller's frame gives us the
ability to completly re-construct large arguments in memory.
A. 2D Matrix Overview
How is Multi-Dimensional Data stored in memory?
int Array[2][3] = {{1,2,3},{4,5,6}};
Read Indexes from left to right - 2 groups of 3 elements each.
Memory is one-dimensional/flat - we must somehow "map"
this array into flat memory.
Row\Column 0 1 2
0 1 2 3
1 4 5 6
2 groups of 3 elements each
This can be "mapped" to "flat" memory in 2 ways:
ROW MAJOR ORDER COLUMN MAJOR ORDER
Mem[Array] 1 1
Mem[Array+4] 2 4
Mem[Array+8] 3 2
Mem[Array+12] 4 5
Mem[Array+16] 5 3
Mem[Array+20] 6 6
Row Major - Store whole "rows" first (C/C++ Style)
Column Major - Store whole "columns" first (Fortran Style)
To compute the Flat address of a specific element:
ROW MAJOR ORDER: Work from left to right multiplying
index by sum of size of remaining sizes
Ex: Array[1][0] from above
Mem[Array+1*3*sizeof(int)+0*sizeof(int)] = Mem[Array+12]
COLUMN MAJOR ORDER: Work from right to left multiplying
index by sum of size of remaining sizes
Ex: Array[1][0] from above
Mem[Array+0*2*sizeof(int)+1*sizeof(int)] = Mem[Array+4]
int Array[2][3][4] = { {{1,2,3,4}, {5,6,7,8}, {9,10,11,12}},
{ {13,14,15,16},{17,18,19,20},{21,22,23,24}} }
2 groups of {3 groups of 4 elements each}
ROW MAJOR ORDER: Work from left to right multiplying
index by size
Ex: Array[1][0][2] (15) from above
Mem[Array+1*12*sizeof(int)+0*sizeof(int)*4+2*sizeof(int)] =
Mem[Array+48+8] = Mem[Array+56]
Comprehensive - All material that was on test #1 may also appear on test #2.
(Although only ~5-15% will be old material)
Chapter 3 & Appendix A, Floating Point Portions of Chapter 4
ASM Instructions Conversion to/from Hex/Binary
Address Calculations/Memory Usage
Subroutines
Register Usage Conventions
Stack Usage/Conventions/Frames
Recursive Subroutines
SPIM
Assembler Directives
Working with Arrays / Characters / etc.
MIPS system call & usage
Arrays & Pointers
Floating Point Co-Pro
Be able to write a recursive subroutine with correct register usage.
Be able to write short assembly language programs.
Be able to understand accessing and manipulating the different data types in memory: words, bytes, etc.
Understand the different memory segments and their usage.
Be able to determine the basic function of a small segment of code. I.e. be able to tell me what it's doing. For exampel, be
able to tell me when a formula is being computed and what that formula is.
III. Next Time:
A. Lab #2 Due Time changed slightly...
B. Hw #7 Assignment Time changed slightly