$t2 ... $t7 —— $a0, $v0, $zero. S - saved. T - temporary. a0 - argument.
v0 - return value. These symbolic representations are key to make function calls. functions record using a stack,
Byte = 8 binary bits -- smallest data type that is typically used
bit = binary 0 or 1
Each byte would have it's own address..and it is uses ASCII characters
ASCII: 8 bits → 1 character
data type is the size of a type. Memory is byte addressable, and every
character or byte has its own address..and this allows you to do string manipulation easily
Add $7, $5, $6 --this is an instruction but what does it mean
the contents of register 5 gets added to the contents of register 6 ..and the result will be stored in register 7
load- Memory -> register
ex of load word : lw $7, 4($8)
store- putting it back out into memory
Begin data - 0
Int var 1 - x90000
Int var 2 - x90004
Int var 3 - x90008
Program counter is increasing it by 4
$12 = 11011001
$2 = 01110010
---------------
01010000
basically 0 and 1 = 0
0 and 0 = 0
1 and 1 = 1
1 and 0 = 0
0 is false
1 is true
$12 = 1 1 0 1 1 0 0 1
$2 = 0 1 1 1 0 0 1 0
---------------
11 1 1 1 01 1
0 or 1 = 1
1 or 1 = 1
0 or 0 = 0
Processor goes to read the value in register 8, then it adds the constant, which is 12, the constant is expressed in a decimal number 12 aka C, so you will get 9000c, and that will be the memory address you want to store on, and you want to WRITE to $9
beq $7, $8, if _ 22
Add
Sub
And
Or
If _22: lw
Sw
Add
subtract
if(the contents of register $7 and $8 are equal){
then go down to the if_22 instruction ..start at the lw..and go down until if_22 ends,
} else {
it will start at the beginning at add and just go all the way down through all the instructions.
}
|opcode | reg | reg | reg | X | function
|_6_____|_5___|_5___|__5__ |_5 |_____6____ = 32 bits
3 registers. 2 src, 1 destination, but the order is diff from assembly language
the X is archaic so we dont use that in class
function - differentiates between the instructions if it's an add or subtract etc
|opcode | reg | reg| offset /constant
|_6_____|_5___|__5_|__16______ = 32 bits
opcode- as opposed to the r-format..this is going to tell u if its bne/lw/sw/ beq (1-63 or 1 - x3F) 63 i format instructions
reg - 2
offset -*covered previously*
8 *10^0 or 8*1 = 8
7 * 10^1 or 7*10 = 70
3 * 10^2 or 3*100 = 300
4* 10^3 or 4*1000 - 4000
1* 2^0 or 1*1 = 1
1 * 2^1 or 1*2 =2
0 * 2^2 or 0*4 =0
1 * 2^3 or 1*8 =8
add $7, $6, $5
$6 - 00110 (extra 0 bc 5 bits)
1 *0 = 0
+ 2* 1 = 2
4 * 1 = 4
8 * 0 = 0
$5 - 01001
1*1 = 1
2*0 = 0
4*1 = 4
8*0 = 0
$7 - 00111
1*1= 1
2* 1 = 2
4 *1 = 4
8*0 =0
the X field thats archaic is going to be 00000
function code(dont have to memorize) x20
x2 0
00[10 0000]
becomes
opcode src $6 src $5 dest $7 X function
000000 00110 00101 00111 00000 10 0000
0000 - 0
0010 - 2
1000 - 8
0011- 3
0101 - 5
1100 - C(12)
0000 - 0
0000- 0
so the answer would be 0x00C53820 --> add $7, $6, $5
0x is just hex
lw $7, 4($8)
lw is x23 - 0010 0011
2 - 0010
3- 0011
$7- 00111
$8 -01000
4- 0000000000000100
src(5bits) - 01000
dest(5bits) - 00111
offset(16bits) - 0000000000000100
[1000] [11 01] [000 0] [0111] [0000] [0000] [0000] [0100]
8 D(13) 0 7 0 0 0 4
0x8D070004
sw - x2B
2 - 0010
B(11)- 1011
opcode - 101011
rs $12 - 01100
rt $9- 01001
offset- 1111111111111011100
4 - 0000000000000100
to change it negative flip 0s to 1s vice versa +4
-4 - 1111111111111011 100
101011110010011111111111111011 binary
1.Execution time--how long does it take to run certain programs
2. Alternative is throughput - in a certain amount of time how much stuff can i get done --this is good for i/o
performance = 1/ execution time
As the execution time gets bigger, performance gets worse
Better performance means execution time is smaller
Performance A Execution B
_____________ = _________________
Performance A Execution A
L0: registers
L1: on chip sram
L2: off chip sram
L3: dram /main mem
L4: local disks/local secondary storage
L5: remote secondary storage
L0 is smallest, fastest, costliest..L5 is slowest, largest, cheapest
register - fraction of a clock cycle vs Main memory - 200 clock cycles
Temporal locality of references. If it’s not in the cache the first time, it’s added, and you can quickly pull it up again.
Spatial locality of reference - if you access that memory location, you’re likely to access nearby memory locations
cache hit - system went into the cache and found it.
Anytime you have a cache miss, the system must go out and get not only that memory address but also the surrounding addresses (a block)
-hit rate (% of hits)
-hit speed(how fast do U get hits)
-miss penalty (how slow are the misses)
A better alternative is A DIRECT MAPPED CACHE.. where you only have one legal slot in the cache. This increases the hit speed !