View

Computer Science

[MIPS] MIPS Registers & Instructions RegistersNameNumberDescription$zero, $00contains the value 0$at1reserved for assembler$v0 - $v12-3values returned by functions$a0 - $a34-7arguments to functions$t0 -  $t78-15temporary variables $s0 - $s716-23saved values $t8 - $t924-25more temporary registers$sp29stack pointer to the top of stack$ra31return addressTemporary vs. Saved RegistersMIPS convention specifies how the registers are suppo.. Show More
[MIPS] Recursion Example - Fibonacci In MIPS, we can implement recursive functions using stack. The stack is necessary to keep track of values in between calls. Let's try implementing the Fibonacci function. Pseudocode in C:int fib (int n) { if (n Code in MIPS Assembly: We will learn how to write a recursive function in MIPS assembly language using two approaches: an intuitive approach and the standard approach. For the intuitive a.. Show More
[MIPS] Stacks In MIPS architecture, the stack grows downward in terms of memory -- when an element is pushed into a stack, it should be stored in an address lower than that of the previous element. We assume the address of the topmost (newest) element in the stack is the one stored in the stack pointer register $sp. There are several ways to implement the push or pop instructions. Below are some examples. Pus.. Show More
[MIPS] Arrays and Strings "MEMORY is a large single-dimensional array, with the address acting as the index"ArraysSince an integer takes up a word, an integer array can be represented through a sequence of words in memory. 1 word is 4 bytes of memory, so the byte address of an integer element is always 4 bytes greater than that of the previous element in the array. Note that in MIPS, therefore all words start at addresse.. Show More