; ; group_a, test 3 ; ; Basic coverage for test boilerplate. Because this test is designed ; to validate enough capabilities to run boilerplate code, it does not ; use the boilerplate as-is. ; ; Covers: ; ; push a ; push b ; pop a ; pop b ; pop pc (ret) ; call disp ; ; NOTE: subtest number is set statically (don't have stores yet) ; ; NOTE: This code should not be included in composed tests, as it doesn't ; follow normal conventions. ; _start: br _start_tests ; Go run stuff. ; Data sections to report group, test and subtest number test_group: defb 0x61 ; group 'a' test_num: defb 0x03 ; test 3 subtest: defb 0x01 ; subtest 1 (only 1 subtest here) pass: ld.16 c,0xbd10 fail: halt _start_tests: ; Begin test here ; Set up stack pointer ld.16 a,0x7000 copy sp,a ; Try a few pushes and pops ; First check SP tracking copy a,sp cmpb.ne.16 a,0x7000,fail push a copy a,sp cmpb.ne.16 a,0x6ffe,fail pop a copy a,sp cmpb.ne.16 a,0x7000,fail ; Now, let's see if value is preserved ld.16 a,0x1234 push a copy b,a ld.16 a,0x4321 cmpb.eq.16 a,b,fail pop a cmpb.ne.16 a,b,fail ; Get tricky now. We'll test "pop pc", which in effect ; is a branch. ld.16 a,br_tgt push a ld.16 a,0xf0f0 pop pc ; branch, with 0xf0f0 in a halt ; shouldn't get here halt halt halt halt br_tgt: cmpb.ne.16 a,0xf0f0,fail ; Okay, now a real call and return. ; First, verify SP is 0x7000 copy a,sp cmpb.ne.16 a,0x7000,fail ; Load a with value to pass to proc ld.16 a,0x5406 call foobar ; Verify return value from proc cmpb.ne.16 a,0xf0f0,fail ; Verify proper stack tracking copy a,sp cmpb.ne.16 a,0x7000,fail ; That's enough for now. br pass foobar: cmpb.ne.16 a,0x5406,fail ld.16 a,0xf0f0 pop pc