ApisNecros 3 tygodni temu
rodzic
commit
146e649587
4 zmienionych plików z 31 dodań i 0 usunięć
  1. 10 0
      tests/jumps.icasm
  2. 13 0
      tests/labels.icasm
  3. 4 0
      tests/multiply.icasm
  4. 4 0
      tests/output.icasm

+ 10 - 0
tests/jumps.icasm

@@ -0,0 +1,10 @@
+// Countdown from 15 to 0 by increments of 5
+ld 0d20, 5
+ld 0d21, 15
+ld 0d22, -1
+mult 0d20, 0d22, 0d25
+jz 0d21, 14
+add 0d25, 0d21, 0d21
+jnz 1, 4
+out 0d21
+hlt

+ 13 - 0
tests/labels.icasm

@@ -0,0 +1,13 @@
+ld 0d19, 0              // jpt, jpf, eq, lt register
+ld 0d20, 10             // loop counter
+ld 0d30, 0              // lower number
+ld 0d31, 1              // higher number
+ld 0d33, 0              // storage space
+Fibonacci:
+add 0d31, 0, 0d33       // Move higher number to a storage point
+add 0d31, 0d30, 0d31    // Add higher and lower number, and store in higher number slot
+add 0d33, 0, 0d30       // Move stored number to lower number slot
+add 0d20, -1, 0d20      // Subtract 1 from the loop counter
+eq 0d20, 0, 0d19        // Check if the loop counter is 0
+jpf 0d19, Fibonacci + 1 // Loop the function if not
+hlt                     // Otherwise, exit

+ 4 - 0
tests/multiply.icasm

@@ -0,0 +1,4 @@
+ld 0d6, 15
+ld 0d7, 5
+mult 0d6, 0d7, 0d8
+hlt

+ 4 - 0
tests/output.icasm

@@ -0,0 +1,4 @@
+ld 0d10, 44
+out 21
+out 0d10
+hlt