From 67bb27e9f5beec4d8ca0a6c29f045d5f23d6f40f Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 28 Feb 2021 17:25:57 +0700 Subject: [lang] Reorganize language learning archive --- mips/chapter-2/exercise-1/a.s | 20 ------------------ mips/chapter-2/exercise-1/b.s | 19 ----------------- mips/chapter-2/exercise-1/c.s | 15 -------------- mips/chapter-2/exercise-1/d.s | 13 ------------ mips/chapter-2/exercise-1/e.s | 18 ---------------- mips/chapter-2/exercise-1/f.s | 17 --------------- mips/chapter-2/exercise-1/g.s | 19 ----------------- mips/chapter-2/exercise-1/h.s | 20 ------------------ mips/chapter-2/exercise-1/i.s | 12 ----------- mips/chapter-2/exercise-1/j.s | 16 -------------- mips/chapter-2/exercise-1/k.s | 28 ------------------------- mips/chapter-2/exercise-1/l.s | 22 -------------------- mips/chapter-2/exercise-1/m.s | 17 --------------- mips/chapter-2/exercise-1/n.s | 16 -------------- mips/chapter-2/exercise-1/o.s | 17 --------------- mips/chapter-2/exercise-1/p.s | 21 ------------------- mips/chapter-2/exercise-1/q.s | 20 ------------------ mips/chapter-2/exercise-1/r.s | 16 -------------- mips/chapter-2/exercise-1/s.s | 16 -------------- mips/chapter-2/exercise-3.s | 22 -------------------- mips/chapter-2/exercise-5.s | 22 -------------------- mips/chapter-3/exercise-10.s | 41 ------------------------------------ mips/chapter-3/exercise-11.s | 41 ------------------------------------ mips/chapter-3/exercise-13.s | 18 ---------------- mips/chapter-3/exercise-14.s | 19 ----------------- mips/chapter-3/exercise-15.s | 19 ----------------- mips/chapter-3/exercise-16.s | 19 ----------------- mips/chapter-3/exercise-3.s | 20 ------------------ mips/chapter-3/exercise-4.s | 20 ------------------ mips/chapter-3/exercise-6.s | 47 ------------------------------------------ mips/chapter-3/exercise-7.s | 47 ------------------------------------------ mips/mips.pdf | Bin 643292 -> 0 bytes 32 files changed, 677 deletions(-) delete mode 100644 mips/chapter-2/exercise-1/a.s delete mode 100644 mips/chapter-2/exercise-1/b.s delete mode 100644 mips/chapter-2/exercise-1/c.s delete mode 100644 mips/chapter-2/exercise-1/d.s delete mode 100644 mips/chapter-2/exercise-1/e.s delete mode 100644 mips/chapter-2/exercise-1/f.s delete mode 100644 mips/chapter-2/exercise-1/g.s delete mode 100644 mips/chapter-2/exercise-1/h.s delete mode 100644 mips/chapter-2/exercise-1/i.s delete mode 100644 mips/chapter-2/exercise-1/j.s delete mode 100644 mips/chapter-2/exercise-1/k.s delete mode 100644 mips/chapter-2/exercise-1/l.s delete mode 100644 mips/chapter-2/exercise-1/m.s delete mode 100644 mips/chapter-2/exercise-1/n.s delete mode 100644 mips/chapter-2/exercise-1/o.s delete mode 100644 mips/chapter-2/exercise-1/p.s delete mode 100644 mips/chapter-2/exercise-1/q.s delete mode 100644 mips/chapter-2/exercise-1/r.s delete mode 100644 mips/chapter-2/exercise-1/s.s delete mode 100644 mips/chapter-2/exercise-3.s delete mode 100644 mips/chapter-2/exercise-5.s delete mode 100644 mips/chapter-3/exercise-10.s delete mode 100644 mips/chapter-3/exercise-11.s delete mode 100644 mips/chapter-3/exercise-13.s delete mode 100644 mips/chapter-3/exercise-14.s delete mode 100644 mips/chapter-3/exercise-15.s delete mode 100644 mips/chapter-3/exercise-16.s delete mode 100644 mips/chapter-3/exercise-3.s delete mode 100644 mips/chapter-3/exercise-4.s delete mode 100644 mips/chapter-3/exercise-6.s delete mode 100644 mips/chapter-3/exercise-7.s delete mode 100644 mips/mips.pdf (limited to 'mips') diff --git a/mips/chapter-2/exercise-1/a.s b/mips/chapter-2/exercise-1/a.s deleted file mode 100644 index 4da4645..0000000 --- a/mips/chapter-2/exercise-1/a.s +++ /dev/null @@ -1,20 +0,0 @@ -# t3 = t4 + t5 - t6 - .text -main: - li $t4, 4 # t4 = 4 - li $t5, 5 # t5 = 5 - li $t6, 6 # t6 = 6 - - add $t3, $t4, $t5 # t3 = t4 + t5 - sub $t3, $t3, $t6 # t3 -= t6 - - li $v0, 1 # print integer - move $a0, $t3 # at t3 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/b.s b/mips/chapter-2/exercise-1/b.s deleted file mode 100644 index fa590b5..0000000 --- a/mips/chapter-2/exercise-1/b.s +++ /dev/null @@ -1,19 +0,0 @@ -# s3 = t2 / (s1 - 54321) - .text -main: - li $t2, 69 # t2 = 69 - li $s1, 54324 # s1 = 54324 - - sub $s1, $s1, 54321 # s1 -= 54321 - div $t3, $t2, $s1 # t3 = t2 / s1 - - li $v0, 1 # print integer - move $a0, $t3 # at a0 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/c.s b/mips/chapter-2/exercise-1/c.s deleted file mode 100644 index 370af96..0000000 --- a/mips/chapter-2/exercise-1/c.s +++ /dev/null @@ -1,15 +0,0 @@ -# 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 diff --git a/mips/chapter-2/exercise-1/d.s b/mips/chapter-2/exercise-1/d.s deleted file mode 100644 index e20cd4c..0000000 --- a/mips/chapter-2/exercise-1/d.s +++ /dev/null @@ -1,13 +0,0 @@ -# print t3 - .text -main: - li $v0, 1 # print integer - move $a0, $t3 # at t3 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/e.s b/mips/chapter-2/exercise-1/e.s deleted file mode 100644 index d35702d..0000000 --- a/mips/chapter-2/exercise-1/e.s +++ /dev/null @@ -1,18 +0,0 @@ -# read to and echo t0 - .text -main: - li $v0, 5 # read integer to v0 - syscall - - move $t0, $v0 # t0 = v0 - - 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 program run - syscall diff --git a/mips/chapter-2/exercise-1/f.s b/mips/chapter-2/exercise-1/f.s deleted file mode 100644 index 2ec14ef..0000000 --- a/mips/chapter-2/exercise-1/f.s +++ /dev/null @@ -1,17 +0,0 @@ -# a0 = array - .data -array: .word 4, 20, 6, 9 - - .text -main: - - li $v0, 1 # print integer - la $a0, array # address of array - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/g.s b/mips/chapter-2/exercise-1/g.s deleted file mode 100644 index e9d8f8f..0000000 --- a/mips/chapter-2/exercise-1/g.s +++ /dev/null @@ -1,19 +0,0 @@ -# t8 = *a0 - .data -array: .word 4, 20, 6, 9 - - .text -main: - la $a0, array # a0 = array - lw $t8, ($a0) # t8 = *a0 - - li $v0, 1 # print integer - move $a0, $t8 # at t8 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/h.s b/mips/chapter-2/exercise-1/h.s deleted file mode 100644 index eaf63bd..0000000 --- a/mips/chapter-2/exercise-1/h.s +++ /dev/null @@ -1,20 +0,0 @@ -# a0[4] = 32768 - .data -array: .word 4, 2, 0, 6, 9 - - .text -main: - la $a0, array # t0 = array - li $t1, 32768 # t1 = 32768 - sw $t1, 16($a0) # t0[4] = t1 - - li $v0, 1 # print integer - lw $a0, 16($a0) # at t0[4] - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/i.s b/mips/chapter-2/exercise-1/i.s deleted file mode 100644 index 8754525..0000000 --- a/mips/chapter-2/exercise-1/i.s +++ /dev/null @@ -1,12 +0,0 @@ -# print Hello, World! - .data -hello: .asciiz "Hello, World!\n" - - .text -main: - li $v0, 4 # print string - la $a0, hello # hello - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/j.s b/mips/chapter-2/exercise-1/j.s deleted file mode 100644 index 95eccc7..0000000 --- a/mips/chapter-2/exercise-1/j.s +++ /dev/null @@ -1,16 +0,0 @@ -# t7 = abs(t0) - .text -main: - li $t0, -420 # t0 = -420 - abs $t7, $t0 # t7 = abs(t0) - - li $v0, 1 # print integer - move $a0, $t7 # at t7 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/k.s b/mips/chapter-2/exercise-1/k.s deleted file mode 100644 index 60c0038..0000000 --- a/mips/chapter-2/exercise-1/k.s +++ /dev/null @@ -1,28 +0,0 @@ -# while (t0) { s1 += t0; t0 = *++t2; } - .data -array: .word 4, 2, 0, 6, 9 - - .text -main: - la $t2, array # t2 = array - lw $t0, ($t2) # t0 = *t2 - li $s1, 0 # s1 = 0 - -while: - beqz $t0, end # if (!t0) goto end - add $s1, $s1, $t0 # s1 += t0 - addi $t2, $t2, 4 # t2++ - lw $t0, ($t2) # t0 = *t2 - j while # goto while -end: - - li $v0, 1 # print integer - move $a0, $s1 # at s1 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/l.s b/mips/chapter-2/exercise-1/l.s deleted file mode 100644 index 73b999d..0000000 --- a/mips/chapter-2/exercise-1/l.s +++ /dev/null @@ -1,22 +0,0 @@ -# for (t1 = 99; t1 > 0; v0 += t1--) - .text -main: - li $v0, 0 # v0 = 0 - li $t1, 99 # t1 = 99 -for: - blez $t1, end # if (t1 <= 0) goto end - add $v0, $v0, $t1 # v0 += t1 - addi $t1, $t1, -1 # t1-- - j for # goto for -end: - - move $a0, $v0 # a0 = v0 - li $v0, 1 # print integer at a0 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/m.s b/mips/chapter-2/exercise-1/m.s deleted file mode 100644 index e02f924..0000000 --- a/mips/chapter-2/exercise-1/m.s +++ /dev/null @@ -1,17 +0,0 @@ -# t0 = 0x7fffffff - 0x80000000 - .text -main: - li $t2, -0x80000000 # t2 = 0x80000000 - li $t1, 0x7fffffff # t1 = 0x7fffffff - add $t0, $t1, $t2 # t0 = t1 - t2 - - 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 program run - syscall diff --git a/mips/chapter-2/exercise-1/n.s b/mips/chapter-2/exercise-1/n.s deleted file mode 100644 index 4394ebf..0000000 --- a/mips/chapter-2/exercise-1/n.s +++ /dev/null @@ -1,16 +0,0 @@ -# s0 *= -1 - .text -main: - li $s0, 420 # s0 = 420 - neg $s0, $s0 # s0 = -s0 - - li $v0, 1 # print integer - move $a0, $s0 # at s0 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/o.s b/mips/chapter-2/exercise-1/o.s deleted file mode 100644 index 06dfc5c..0000000 --- a/mips/chapter-2/exercise-1/o.s +++ /dev/null @@ -1,17 +0,0 @@ -# s1 *= a0 - .text -main: - li $s1, 420 # s1 = 420 - li $a0, 69 # a0 = 69 - mul $s1, $s1, $a0 # s1 *= a0 - - li $v0, 1 # print integer - move $a0, $s1 # at s1 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/p.s b/mips/chapter-2/exercise-1/p.s deleted file mode 100644 index a15958f..0000000 --- a/mips/chapter-2/exercise-1/p.s +++ /dev/null @@ -1,21 +0,0 @@ -# s2 = srt(s0**2 + 56) / a3 - .text -main: - li $s0, 420 # s0 = 420 - li $a3, 69 # a3 = 69 - - mul $t0, $s0, $s0 # t0 = s0 ** 2 - addi $a0, $t0, 56 # a0 = t0 + 56 - jal srt # v0 = srt(a0) # srt is undefined - div $s2, $v0, $a3 # s2 = v0 / a3 - - li $v0, 1 # print integer - move $a0, $s0 # at s2 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/q.s b/mips/chapter-2/exercise-1/q.s deleted file mode 100644 index 47069cd..0000000 --- a/mips/chapter-2/exercise-1/q.s +++ /dev/null @@ -1,20 +0,0 @@ -# s3 = s1 - s2 / s3 - .text -main: - li $s1, 69 # s1 = 69 - li $s2, 20 # s2 = 20 - li $s3, 4 # s3 = 4 - - div $s3, $s2, $s3 # s3 = s2 / s3 - sub $s3, $s1, $s3 # s3 = s1 - s3 - - li $v0, 1 # print integer - move $a0, $s3 # at s3 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/r.s b/mips/chapter-2/exercise-1/r.s deleted file mode 100644 index c362e64..0000000 --- a/mips/chapter-2/exercise-1/r.s +++ /dev/null @@ -1,16 +0,0 @@ -# s4 <<= 3 - .text -main: - li $s4, 420 # s4 = 420 - sll $s4, $s4, 3 # s4 <<= 3 - - li $v0, 1 # print integer - move $a0, $s4 # at s4 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-1/s.s b/mips/chapter-2/exercise-1/s.s deleted file mode 100644 index 07c8a12..0000000 --- a/mips/chapter-2/exercise-1/s.s +++ /dev/null @@ -1,16 +0,0 @@ -# s5 *= pi - .text -main: - li $s5, 420 # s5 = 420 - mul $s5, $s5, 3 # s5 *= 3 - - li $v0, 1 # print integer - move $a0, $s5 # at s5 - syscall - - li $v0, 11 # print character - li $a0, 10 # newline - syscall - - li $v0, 10 # terminate program run - syscall diff --git a/mips/chapter-2/exercise-3.s b/mips/chapter-2/exercise-3.s deleted file mode 100644 index d82da72..0000000 --- a/mips/chapter-2/exercise-3.s +++ /dev/null @@ -1,22 +0,0 @@ -# t0 = (s1 - s0 / s2) * s4 - .text -main: - li $s1, 4 # s1 = 4 - li $s0, 20 # s0 = 20 - li $s2, 6 # s2 = 6 - li $s4, 9 # s4 = 9 - - div $t0, $s0, $s2 # t0 = s0 / s2 - sub $t0, $s1, $t0 # t0 = s1 - t0 - mul $t0, $t0, $s4 # t0 *= s4 - - 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-2/exercise-5.s b/mips/chapter-2/exercise-5.s deleted file mode 100644 index ffb4058..0000000 --- a/mips/chapter-2/exercise-5.s +++ /dev/null @@ -1,22 +0,0 @@ -# t0 = s0/8 - s1*2 + s2 - .text -main: - li $s0, 69 # s0 = 20 - li $s1, 4 # s1 = 4 - li $s2, 20 # s2 = 20 - - sra $t0, $s0, 3 # t0 = s0 >> 3 - sll $t1, $s1, 1 # t1 = s1 << 1 - sub $t0, $t0, $t1 # t0 -= t1 - add $t0, $t0, $s2 # t0 += s2 - - 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-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 diff --git a/mips/mips.pdf b/mips/mips.pdf deleted file mode 100644 index 4a38047..0000000 Binary files a/mips/mips.pdf and /dev/null differ -- cgit 1.4.1