MIPS Flashcards
How long are MIPS addresses
32 bits
how long are mips instructions?
32 bits
How is a MIPS instruction held in memory?
Held in 4 consecutive memory locations
How many registers inside a mips?
32($0-$31)
What can arithmetic operations operate on?
Data read from registers
What is RISC based architecture?
“load and store”, only load and store instructions access memory, all other instructions access registers
Describe R-type instructions
Register operands - all arithmetic
op = operation or type of the instruction
rs = first register argument (source)
rt = second register argument (source)
rd = result of the operation (destination)
shamt = shift amount (ignore at present)
funct = particular type of the operation
op always equal to zero, so funct describes what the instruction does
Name the key difference between add and addu
addu stands for add unsigned, add is assumed to be working with 2’s complement singed numbers
Real difference is that signed add “Throws interrupt” whenever overflow occurs for the signed operation
addu ignores the overflow
How do you calculate the memory address?
sum the displacement value given and the value stored inside the register.
If the displace read 0x0008 how many words is that
2 words displacement
What are I type instructions used for?
memory access instructions
instructions that require a constant value
branch instructions
consider I type
lw $20, 0x1234($5)
in what order will the op, rs, rt, and offset be
lw, 5, 20, 0x1234
Describe how lw instruction
lw $10, 0($x)
– copies the word from address Z into register $10.
– A high-level language view would be that array element Z[0] is
copied into register 10.
Describe how sw instruction
sw $10, 80($x)
– copies the value from register $10 into the memory location 20
word offsets from Z.
– A high-level language view would be that the contents of register
10 is copied into array element Z[20].
What is an I type (immediate value)?
instead of off set, actual value is passed into instruction to be added or whatever to other register and store in register
What is the offset when concerning a branch command?
the NUMBER of INSTRUCTIONS to branch over starting from the instruction following the branch
PC = PC+ 4 + 0xFFFFABCD * 4
How do we store a 32 bit address in a register?
Use a load upper instruction and then use OR instruction with other half of immediate and store in the same register
At what address is the executable code loaded from?
0x00400000, the text segment
What is an assembly directive?
They tell the assembler what to do
What are the two key directives
.data, .text, they are concerned with the way the assembly language program is laid out in memory
Where is the data loaded at?
0x1001000, known as the dynamic data segment
What is the .word directive do?
Its a data layout directive, it allows the assembly programmer to describe the data in a more natural way then binary,
in this case, the 32 bit words that follow are written into the dynamic data segment of the program
vals: .word 4, 5, 8, 0
describe what the assembly directive .word 10,20,30 do?
Store 10,20,30 in successive memory locations as 32 bit words
What is an assembly label?
A colon after a word indicates an address label, this is a symbolic representation of that address.
These can be used withing the assembly code and the assembler will put in the correct address values