about summary refs log tree commit diff
path: root/mips/chapter-3
diff options
context:
space:
mode:
Diffstat (limited to 'mips/chapter-3')
-rw-r--r--mips/chapter-3/exercise-10.s41
-rw-r--r--mips/chapter-3/exercise-11.s41
-rw-r--r--mips/chapter-3/exercise-13.s18
-rw-r--r--mips/chapter-3/exercise-14.s19
-rw-r--r--mips/chapter-3/exercise-15.s19
-rw-r--r--mips/chapter-3/exercise-16.s19
-rw-r--r--mips/chapter-3/exercise-3.s20
-rw-r--r--mips/chapter-3/exercise-4.s20
-rw-r--r--mips/chapter-3/exercise-6.s47
-rw-r--r--mips/chapter-3/exercise-7.s47
10 files changed, 0 insertions, 291 deletions
diff --git a/mips/chapter-3/exercise-10.s b/mips/chapter-3/exercise-10.s
deleted file mode 100644
index f3ddeef..0000000
--- a/mips/chapter-3/exercise-10.s
+++ /dev/null
@@ -1,41 +0,0 @@
-# print -35 in 8-bit two-complement binary
-	.text
-main:
-	li	$t0,	-35		# t0 = -35
-	li	$t1,	0		# t1 = 0
-	li	$t8,	8		# t8 = 8
-
-reverse:
-	beqz	$t8,	prefix		# if (!t8) goto prefix
-	andi	$t2,	$t0,	1	# t2 = t0 & 1
-	sra	$t0,	$t0,	1	# t0 >>= 1
-	sll	$t1,	$t1,	1	# t1 <<= 1
-	add	$t1,	$t1,	$t2	# t1 += t2
-	addi	$t8,	$t8,	-1	# t8--
-	j	reverse			# goto reverse
-
-prefix:
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	li	$v0,	11		# print character
-	li	$a0,	98		# b
-	syscall
-	li	$t8,	8		# t8 = 8
-
-print:
-	beqz	$t8,	end		# if (!t8) goto end
-	li	$v0,	1		# print integre
-	andi	$a0,	$t1,	1	# a0 = t1 & 1
-	syscall
-	sra	$t1,	$t1,	1	# t1 >>= 1
-	addi	$t8,	$t8,	-1	# t8--
-	j	print			# goto print
-
-end:
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-11.s b/mips/chapter-3/exercise-11.s
deleted file mode 100644
index f47f29f..0000000
--- a/mips/chapter-3/exercise-11.s
+++ /dev/null
@@ -1,41 +0,0 @@
-# print -32 in 8-bit two-complement binary
-	.text
-main:
-	li	$t0,	-32		# t0 = -32
-	li	$t1,	0		# t1 = 0
-	li	$t8,	8		# t8 = 8
-
-reverse:
-	beqz	$t8,	prefix		# if (!t8) goto prefix
-	andi	$t2,	$t0,	1	# t2 = t0 & 1
-	sra	$t0,	$t0,	1	# t0 >>= 1
-	sll	$t1,	$t1,	1	# t1 <<= 1
-	add	$t1,	$t1,	$t2	# t1 += t2
-	addi	$t8,	$t8,	-1	# t8--
-	j	reverse			# goto reverse
-
-prefix:
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	li	$v0,	11		# print character
-	li	$a0,	98		# b
-	syscall
-	li	$t8,	8		# t8 = 8
-
-print:
-	beqz	$t8,	end		# if (!t8) goto end
-	li	$v0,	1		# print integre
-	andi	$a0,	$t1,	1	# a0 = t1 & 1
-	syscall
-	sra	$t1,	$t1,	1	# t1 >>= 1
-	addi	$t8,	$t8,	-1	# t8--
-	j	print			# goto print
-
-end:
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-13.s b/mips/chapter-3/exercise-13.s
deleted file mode 100644
index 6779d11..0000000
--- a/mips/chapter-3/exercise-13.s
+++ /dev/null
@@ -1,18 +0,0 @@
-# print(int('204', 8))
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	2	# t0 += 2
-	sll	$t0,	$t0,	6	# t0 *= 8 * 8
-	addi	$t0,	$t0,	4	# t0 += 4
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-14.s b/mips/chapter-3/exercise-14.s
deleted file mode 100644
index b01b76b..0000000
--- a/mips/chapter-3/exercise-14.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# print(int('204', 7))
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	2	# t0 += 2
-	li	$t1,	49		# t1 = 7 * 7
-	mul	$t0,	$t0,	$t1	# t0 *= t1
-	addi	$t0,	$t0,	4	# t0 += 4
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-15.s b/mips/chapter-3/exercise-15.s
deleted file mode 100644
index 3a16b14..0000000
--- a/mips/chapter-3/exercise-15.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# print(int('204', 6))
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	2	# t0 += 2
-	li	$t1,	36		# t1 = 6 * 6
-	mul	$t0,	$t0,	$t1	# t0 *= t1
-	addi	$t0,	$t0,	4	# t0 += 4
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-16.s b/mips/chapter-3/exercise-16.s
deleted file mode 100644
index 1aa9dec..0000000
--- a/mips/chapter-3/exercise-16.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# print(int('204', 5))
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	2	# t0 += 2
-	li	$t1,	25		# t1 = 5 * 5
-	mul	$t0,	$t0,	$t1	# t0 *= t1
-	addi	$t0,	$t0,	4	# t0 += 4
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-3.s b/mips/chapter-3/exercise-3.s
deleted file mode 100644
index cb2475c..0000000
--- a/mips/chapter-3/exercise-3.s
+++ /dev/null
@@ -1,20 +0,0 @@
-# t0 = 0b10101, using only bit shift and add
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	1	# t0++
-	sll	$t0,	$t0,	2	# t0 <<= 2
-	addi	$t0,	$t0,	1	# t0++
-	sll	$t0,	$t0,	2	# t0 <<= 2
-	addi	$t0,	$t0,	1	# t0++
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-4.s b/mips/chapter-3/exercise-4.s
deleted file mode 100644
index 29888f1..0000000
--- a/mips/chapter-3/exercise-4.s
+++ /dev/null
@@ -1,20 +0,0 @@
-# t0 = 0b11001, using only bit shift and add
-	.text
-main:
-	li	$t0,	0		# t0 = 0
-	addi	$t0,	$t0,	1	# t0++
-	sll	$t0,	$t0,	1	# t0 <<= 1
-	addi	$t0,	$t0,	1	# t0++
-	sll	$t0,	$t0,	3	# t0 <<= 3
-	addi	$t0,	$t0,	1	# t0++
-
-	li	$v0,	1		# print integer
-	move	$a0,	$t0		# at t0
-	syscall
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-6.s b/mips/chapter-3/exercise-6.s
deleted file mode 100644
index 8c1b6fd..0000000
--- a/mips/chapter-3/exercise-6.s
+++ /dev/null
@@ -1,47 +0,0 @@
-# print(hex(0b10101))
-	.text
-main:
-	li	$t0,	21		# t0 = 0b10101
-	li	$t1,	0		# t1 = 0
-	li	$t9,	9		# t9 = 9
-
-reverse:
-	beqz	$t0,	done		# if (!t0) goto done
-	andi	$t2,	$t0,	0xf	# t2 = t0 & 0xf
-	sra	$t0,	$t0,	4	# t0 >>= 4
-	sll	$t1,	$t1,	4	# t1 <<= 4
-	add	$t1,	$t1,	$t2	# t1 += t2
-	j	reverse			# goto reverse
-done:
-
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	li	$v0,	11		# print character
-	li	$a0,	120		# x
-	syscall
-	bnez	$t1,	print		# if (!t1) goto print
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	j	end			# goto end
-
-print:
-	beqz	$t1,	end		# if (!t1) goto end
-	andi	$t2,	$t1,	0xf	# t2 = t1 & 0xf
-	sra	$t1,	$t1,	4	# t1 >>= 4
-	addi	$a0,	$t2,	48	# a0 = chr(t2), sort of
-	ble	$t2,	$t9,	put	# if (t2 <= 9) goto put
-	addi	$a0,	$a0,	7	# a0 += 7
-put:
-	li	$v0,	11		# print character at a0
-	syscall
-	j	print			# goto print
-end:
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall
diff --git a/mips/chapter-3/exercise-7.s b/mips/chapter-3/exercise-7.s
deleted file mode 100644
index 924765d..0000000
--- a/mips/chapter-3/exercise-7.s
+++ /dev/null
@@ -1,47 +0,0 @@
-# print(hex(0b11001))
-	.text
-main:
-	li	$t0,	25		# t0 = 0b11001
-	li	$t1,	0		# t1 = 0
-	li	$t9,	9		# t9 = 9
-
-reverse:
-	beqz	$t0,	done		# if (!t0) goto done
-	andi	$t2,	$t0,	0xf	# t2 = t0 & 0xf
-	sra	$t0,	$t0,	4	# t0 >>= 4
-	sll	$t1,	$t1,	4	# t1 <<= 4
-	add	$t1,	$t1,	$t2	# t1 += t2
-	j	reverse			# goto reverse
-done:
-
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	li	$v0,	11		# print character
-	li	$a0,	120		# x
-	syscall
-	bnez	$t1,	print		# if (!t1) goto print
-	li	$v0,	11		# print character
-	li	$a0,	48		# 0
-	syscall
-	j	end			# goto end
-
-print:
-	beqz	$t1,	end		# if (!t1) goto end
-	andi	$t2,	$t1,	0xf	# t2 = t1 & 0xf
-	sra	$t1,	$t1,	4	# t1 >>= 4
-	addi	$a0,	$t2,	48	# a0 = chr(t2), sort of
-	ble	$t2,	$t9,	put	# if (t2 <= 9) goto put
-	addi	$a0,	$a0,	7	# a0 += 7
-put:
-	li	$v0,	11		# print character at a0
-	syscall
-	j	print			# goto print
-end:
-
-	li	$v0,	11		# print character
-	li	$a0,	10		# newline
-	syscall
-
-	li	$v0,	10		# terminate
-	syscall