about summary refs log tree commit diff
path: root/lang/mips/chapter-2/exercise-1/c.s
diff options
context:
space:
mode:
Diffstat (limited to 'lang/mips/chapter-2/exercise-1/c.s')
-rw-r--r--lang/mips/chapter-2/exercise-1/c.s15
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/mips/chapter-2/exercise-1/c.s b/lang/mips/chapter-2/exercise-1/c.s
new file mode 100644
index 0000000..370af96
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/c.s
@@ -0,0 +1,15 @@
+# sp -= 16
+	.text
+main:
+	addi	$sp,	$sp,	-16	# sp -= 16, may underflow
+
+	li	$v0,	1		# print integer
+	move	$a0,	$sp		# at sp
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall