summaryrefslogtreecommitdiffhomepage
path: root/mips.html.markdown
diff options
context:
space:
mode:
authorSpiderpig86 <slim679975@gmail.com>2018-08-08 22:01:56 -0400
committerSpiderpig86 <slim679975@gmail.com>2018-08-08 22:01:56 -0400
commitb7bb2fc93d9449c35c318d051045c519d5680bb8 (patch)
tree23a32b2b18ba118eff10124f5f650c328a08ceae /mips.html.markdown
parentffff6d9bb31efd2b47bedc9ee07cd68b50c12f47 (diff)
feat(mips.html.markdown): Added entry about arrays
Diffstat (limited to 'mips.html.markdown')
-rw-r--r--mips.html.markdown27
1 files changed, 27 insertions, 0 deletions
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:
+
```