diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 14:41:21 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 14:41:21 +0100 |
commit | 25e1beee38cba662f62f2de85855091a4e718064 (patch) | |
tree | 2a0508e67b3dd673b65fb36c1746296fbcd9331b /cpu/os.asm | |
parent | 40f46cd1ce93d7f8045dda4e0af91670cd681d57 (diff) | |
parent | 2595e3881e0904fc6ecb162775a149f5b0121848 (diff) | |
download | SystDigit-Projet-25e1beee38cba662f62f2de85855091a4e718064.tar.gz SystDigit-Projet-25e1beee38cba662f62f2de85855091a4e718064.zip |
Merge branch 'jonathan' ; add unit tests.
Conflicts:
cpu/alu.ml
Diffstat (limited to 'cpu/os.asm')
-rw-r--r-- | cpu/os.asm | 93 |
1 files changed, 93 insertions, 0 deletions
@@ -4,6 +4,8 @@ # all registers are caller-saved, except SP which is preserved by function calls .text + jal run_unit_tests + li A msghello jal ser_out_msg @@ -90,6 +92,81 @@ add_b_to_string: jz A check_input check_input_ret: jr RA + +# PROCEDURE: run_unit_tests +# ROLE: check that CPU features work correctly ; displays message to serial output +# ARGUMENTS: none +run_unit_tests: + push RA + + li A testbegin + jal ser_out_msg + + li A test0 + jal ser_out_msg + jal unit_test_0 + li A testfail + jz B t0fail + li A testok +t0fail: + jal ser_out_msg + + li A test1 + jal ser_out_msg + jal unit_test_1 + li A testfail + jz B t1fail + li A testok +t1fail: + jal ser_out_msg + + li A test2 + jal ser_out_msg + jal unit_test_2 + li A testfail + jz B t2fail + li A testok +t2fail: + jal ser_out_msg + + li A test3 + jal ser_out_msg + jal unit_test_3 + li A testfail + jz B t2fail + li A testok +t3fail: + jal ser_out_msg + + pop RA + jr RA + +unit_test_0: + li B 1 + + li C 12 + li D 44 + add C C D + sei A C 56 + and B B A + + li C -7 + li D 7 + add C C D + se A C Z + and B B A + + jr RA +unit_test_1: + li B 1 + jr RA +unit_test_2: + li B 1 + jr RA +unit_test_3: + li B 1 + jr RA + # READ-ONLY PROGRAM DATA @@ -104,6 +181,22 @@ endl: error: ascii "Sorry but I'm to stupid to understand that.\n" +testbegin: + ascii "Runing CPU unit tests...\n" +testok: + ascii "OK\n" +testfail: + ascii "FAIL\n" +test0: + ascii "Addition/substraction: " +test1: + ascii "Unsigned multiplication: " +test2: + ascii "Unsigned division: " +test3: + ascii "Signed division/multiplication: " + + .data # Space where command-line is buffered from serial input |