Skip to content

Commit

Permalink
Merge pull request #160 from tomhea/dev
Browse files Browse the repository at this point in the history
refine extensive tests
  • Loading branch information
tomhea authored Jun 21, 2022
2 parents a056de1 + ecc3240 commit fe87ca6
Show file tree
Hide file tree
Showing 104 changed files with 2,966 additions and 1,053 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This project is a **Macro Assembler**, an **Interpreter** and a **Tested Standar

## Hello, World!

A simple fj [hello-world](programs/hello_no-stl.fj) program, not using the standard library:
A simple fj [hello-world](programs/print_tests/hello_no-stl.fj) program, not using the standard library:

```c
def startup @ code_start > IO {
Expand Down Expand Up @@ -56,7 +56,7 @@ def end_loop @ loop_label {
```

The FlipJump assembly supports a ```"Hello, World!"``` syntax for initializing a variable with a string value.
Look at the [hello_world.fj](programs/hello_world.fj) program for more info.
Look at the [hello_world.fj](programs/print_tests/hello_world.fj) program for more info.

Note that all of these macros are already implemented in the standard library:
- startup in [runlib.fj](stl/runlib.fj)
Expand Down Expand Up @@ -133,14 +133,14 @@ other branches:
- conf.json - standard library list file.

**[programs](programs)** (FlipJump programs), for example:
- hello_world.fj - prints hello world :)
- calc.fj - command line 2 hex/dec calculator, ```a [+-*/%] b```.
- func.fj - performs function calls and operations on stack.
- hexlib-*.fj - tests the macros in stl/hexlib.fj.
- quine16.fj - a 16-bits quine by [lestrozi](https://github.com/lestrozi); prints itself.
- pair_ns.fj - simulating the concept of a Class using a namespace.
- print_dec.fj - prints binary variables as decimals.
- multi_comp - simulates a big project
- [hello_world.fj](programs/print_tests/hello_world.fj) - prints hello world :)
- [calc.fj](programs/calc.fj) - command line calculator for 2 hex/dec numbers: ```a [+-*/%] b```.
- [func_tests/](programs/func_tests) - performs function calls and operations on stack.
- [hexlib_tests/](programs/hexlib_tests) - tests for the macros in stl/hexlib.fj.
- [quine16.fj](programs/quine16.fj) - a 16-bits quine by [lestrozi](https://github.com/lestrozi); prints itself.
- [pair_ns.fj](programs/concept_checks/pair_ns.fj) - simulating the concept of a Class using a namespace.
- [print_dec.fj](programs/print_tests/print_dec.fj) - prints binary variables as decimals.
- [multi_comp/](programs/multi_comp) - simulates a big project (compilation of multiple files).

**[tests](tests)** (FlipJump programs), for example:
- compiled/ - the designated directory for the assembled tests files.
Expand Down
3 changes: 0 additions & 3 deletions programs/casting.fj → programs/concept_checks/casting.fj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ hex.print_as_digit h, 0
output '\n'

bit2hex 12, hex, bits
//hex.print_as_digit hex+0*dw, 0
//hex.print_as_digit hex+1*dw, 0
//hex.print_as_digit hex+2*dw, 0
hex.print_as_digit 3, hex, 0
output '\n'
output '\n'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions programs/hexlib_tests/2params/add.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
startup

rep(256, i) test_add i&0xf, i>>4

loop


hex.init


def test_add a, b @ c0_1st, c1_1st, print_1st, c0_2nd, c1_2nd, print_2nd, ah_1st, bh, ah_2nd, end {
hex.add.clear_carry
hex.add ah_1st, bh
hex.add.clear_carry c0_1st, c1_1st
c0_1st:
output '0'
;print_1st
c1_1st:
output '1'
print_1st:
hex.print_as_digit ah_1st, 0
output '-'

hex.add.not_carry
hex.add ah_2nd, bh
hex.add.clear_carry c0_2nd, c1_2nd
c0_2nd:
output '0'
;print_2nd
c1_2nd:
output '1'
print_2nd:
hex.print_as_digit ah_2nd, 0
output '\n'
;end

ah_1st: hex a
ah_2nd: hex a
bh: hex b
end:
}
31 changes: 31 additions & 0 deletions programs/hexlib_tests/2params/add_n.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
startup

ADD_N = 0x0000ffff800040a73dd06622dc0594c9e1b9b001
rep(100, i) test_add_n 4, (ADD_N>>((i%10)*4)&0xf), (ADD_N>>((i/10))*4&0xf)

loop


hex.init


def test_add_n n, a, b @ lt, eq, gt, ah, bh, ch, end {
hex.add n, ah, bh
hex.cmp n, ah, ch, lt, eq, gt

lt:
output '<'
;end
eq:
output '='
;end
gt:
output '>'
;end

ah: hex.vec n, a
bh: hex.vec n, b
ch: hex.vec n, a+b
end:
output '\n'
}
23 changes: 23 additions & 0 deletions programs/hexlib_tests/2params/and.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
startup

rep(256, i) test_and i&0xf, i>>4

loop


hex.init


def test_and a, b @ ah, ah_copy, bh, end {
hex.and ah, bh
hex.and bh, ah_copy
hex.print_as_digit ah, 0
hex.print_as_digit bh, 0
output '\n'
;end

ah: hex a
ah_copy: hex a
bh: hex b
end:
}
31 changes: 31 additions & 0 deletions programs/hexlib_tests/2params/and_n.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
startup

AND_N = 0x0000ffff8000b32cccc69dea2047c8e0ae1e5299
rep(100, i) test_and_n 4, (AND_N>>((i%10)*4)&0xf), (AND_N>>((i/10))*4&0xf)

loop


hex.init


def test_and_n n, a, b @ lt, eq, gt, ah, bh, ch, end {
hex.and n, ah, bh
hex.cmp n, ah, ch, lt, eq, gt

lt:
output '<'
;end
eq:
output '='
;end
gt:
output '>'
;end

ah: hex.vec n, a
bh: hex.vec n, b
ch: hex.vec n, a&b
end:
output '\n'
}
27 changes: 27 additions & 0 deletions programs/hexlib_tests/2params/cmp.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
startup

rep(256, i) test_cmp i&0xf, i>>4

loop


hex.init


def test_cmp a, b @ lt, eq, gt, ah, bh, end {
hex.cmp ah, bh, lt, eq, gt

lt:
output '<'
;end
eq:
output '='
;end
gt:
output '>'
;end
ah: hex a
bh: hex b
end:
output '\n'
}
28 changes: 28 additions & 0 deletions programs/hexlib_tests/2params/cmp_n.fj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
startup

CMP_N = 0x012345 | (0x123456 << 32) | (0x333333 << 64) | (0x654321 << 96)
rep(16, i) test_cmp_n 8, (CMP_N >> ((i&3)*32)) & ((1<<32)-1), (CMP_N >> ((i>>2)*32)) & ((1<<32)-1)

loop


hex.init


def test_cmp_n n, a, b @ lt, eq, gt, ah, bh, end {
hex.cmp n, ah, bh, lt, eq, gt

lt:
output '<'
;end
eq:
output '='
;end
gt:
output '>'
;end
ah: hex.vec n, a
bh: hex.vec n, b
end:
output '\n'
}
Loading

0 comments on commit fe87ca6

Please sign in to comment.