From b7bb2fc93d9449c35c318d051045c519d5680bb8 Mon Sep 17 00:00:00 2001 From: Spiderpig86 Date: Wed, 8 Aug 2018 22:01:56 -0400 Subject: feat(mips.html.markdown): Added entry about arrays --- mips.html.markdown | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'mips.html.markdown') diff --git a/mips.html.markdown b/mips.html.markdown index e56c9fce..ef2043d5 100644 --- a/mips.html.markdown +++ b/mips.html.markdown @@ -330,4 +330,31 @@ hello_world .asciiz "Hello World\n" # Declare a null terminated string .end_macro print(hello_world) + +## ARRAYS ## +.data + list: .word 3, 0, 1, 2, 6 # This is an array of words + char_arr: .asciiz "hello" # This is a char array + buffer: .space 128 # Allocates a block in memory, does + # not automatically clear + # These blocks of memory are aligned + # next each other + +.text + la $s0, list # Load address of list + li $t0, 0 # Counter + li $t1, 5 # Length of the list + + loop: + bgt $t0, $t1, end_loop + + lw $a0, ($s0) + li $v0, 1 + syscall # Print the number + + addi $s0, $s0, 4 # Size of a word is 4 bytes + addi $t0, $t0, 1 # Increment + j loop + end_loop: + ``` -- cgit v1.2.3