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 ---------------------- 21 files changed, 386 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 (limited to 'mips/chapter-2') 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 -- cgit 1.4.1