, , , . , , , . , X 100 int Y- 200. :
X: defs 100*4
Y: defs 200*4
".byte" "defs". "* 4" - , , int 4 . " ". , , , , . X 1 Y 2's:
la $t0,X ; get address of X array into $t0
mov $t1,100 ; number of items in X into $t1
mov $s0,1 ; All X[] to be filled with 1
xlp: st $s0,0($t0) ; write next X[] value
add $t0,$t0,4 ; move to next position in X[] array
add $t1,$t1,-1 ; count down one less item
bne $t1,0,xlp ; keep doing this until we get to zero
la $t0,Y
mov $t1,200
mov $s0,2
ylp: st $s0,0($t0)
add $t0,$t0,4
add $t1,$t1,-1
bne $t1,0,ylp
, , , Mnemonics MIPS .
- . , , . , . , , , , . , , , .
. , . :
X: word 0
mov $t0,100*8 ; how much memory we will need
bal alloc ; get memory -- assume it returns pointer in $t1
la $s0,X ; X pointer address
st $t1,0($s0) ; keep track of start of array
, , . , "X" . "X" - 4 , .
-, "la $t0, X" :
la $t0,X
l $t0,0($t0)
C, , "int X [100];" vs. "int * X = malloc (100 * sizeof (int));". "X [n]", C .