Intro to MIPS Assembly Functions

preview_player
Показать описание
Explains instructions:
j (jump to a label)
jal (same as j but stores PC+4 into $ra)
jra (jumps to the instruction located at address in $ra. It's how you return from a function)

Explains purpose of a stack and a heap. The stack is used to preserve register values whilst between function calls. The heap is used by C's malloc() and Java's new functions to dynamically request memory space as needed.

When creating an object (e.g. new ArrayList()), the OS is not required to know exactly how much memory is needed; this request for memory can be made during run time. In Java, when you relinquish memory by removing the reference (setting the object reference to null), the garbage collector will put the previously claimed memory back into the heap.

In C, there is no garbage collection; memory is returned to the heap by use of keyword free().
Array declaration using 2 methods:
int x[10]; //fixed and static. static means size is declared and fixed during compilation
int* x = malloc(10*sizeof(int));
or better: int* x = (int)malloc(10*sizeof(int)); //cast the void*
Рекомендации по теме
Комментарии
Автор

Hey, what's about special2 instruction, what do?

ajenkaxyok