2 Review: Memory Organization Large single-dimension arrayA memory address is an index into the arrayMemory stores 8 bits in each addressRegisters store 32 bits of informationFor example:Li $t0, 0lw $t0, 0($t1)Then $t0 will contain the data of the first four memory locations6543218 bits of data
3 Review: Registers MIPS has 32 registers, each containing 32 bits Some registers are listed below$zero: constant 0$at: reserved for the assembler$v0 - $v1: function results$a0 - $a3: function arguments$t0 - $t9: temporary$s0 - $s7: temporary
4 Arithmetic Instructions (1/2) Some instructions include:AddSubtractMultiplyDivideMust break expression into simple operationsuse temporary registers ($t0 to $t9) to store intermediate resultsuse load to insert a value into a variableuse store to assign a value to a variable
6 Global variables C program Assembly Program int variable = -42; .data variable: .word -42int r1; r1: .space 4.space allocates empty space in bytes.word allocates 4-byte value followed by the value to store
7 Assember DirectivesAll assembler directives have names that begin with a period (`.').Examples:.word w1allocate a 4-byte word.half h1allocate 2-bytes.byte b1allocate a single byte.ascii “hello"allocate a sequence of bytes and store ASCII values.asciiz “hello"allocate a sequence of bytes and store ASCII values. terminate string with 0 byte (end of string).float.double
8 Input/OutputOn real machines (including real MIPS computers), I/O is very complicatedusually handled by operating systemIn SPIM, I/O is managed by system callssyscall instructionSPIM suspends simulation to perform I/O, then resumes simulation
9 System calls Systems calls are used to interact with the user To make a system calldetermine which service you wantput service’s call code in register $v0put arguments in registers $a0, $a1, etc.execute the syscall instructionresults are in registers $v0, $v1
Your consent to our cookies if you continue to use this website.