Machine and Assembly Language Byte Addressable Memory

(In class notes)

L2

Programs are data. Programs are formed by instructions.

Registers: very fast memory. RAM: we use ram to refer to memory.

L3

slt s, d to be 1, other wise sets is it to be 0. - Notes: needs to know if it’s signed or unsigned. Only works if both are the same.

EX: Negates the value in register 2, 0: if 1<0, sets register 2 to 1. 2, 1, 1: substract dollar 1 from 0, that takes the complement? jr $31 Idea: Register 2 is 0 if register 1 is non-negative. Branch if register 2 is not zero. Otherwise negate register 1.

EX: Put absolute value of register 2 name file .asm vim abs.asm add 1, 8, 0: 0 < 8 = 8, 8 is 0, then you’ve done previous, skip 1 instruction sub 0, 31: number is positive FIX beq 0, ifend sub 0, 32

LOOPING Adss together all even numbers from 1 to 20 incluseve and store answer in register 2 .word 20 lis 3, 0: sets the result to 0 becuase we want to 0, start the loop at 20 and go down. (less code) add 3, 2, 2; line -2 bne 0, -3; line -1 from here, if doesn’t reach 0 we go back to line -3, and come down again jr $31

Use label for us to add new instructions

EX: sample has the address 0x4, which is the location of add 0, $0

lis $2
.word 20
lis $1
.word 2
add $3 $0, $0
top:
	add $3 $3 $2
	sub $2 $2, $1
	bne $2 $0, top
jr $31

label below condition vs above is a loop careful with where you check and put the label…