; ; group_a, test 4 ; ; Verify template code ; ; Magic-1 Validation Suite Test template. Ideally, this code would be ; inserted into the test via a macro or include. However, the Magic-1 ; toolchain is sufficiently primitive that these capabilities are not ; available. ; ; Define COMPOSED if collecting several individual ; tests into a single test. ; ; Each test must: ; o Define test group -> GROUP (single char, a-z) ; o Define test number -> TNUM (byte, 0-255) ; o Preserve the value of SP across the test (exception - if the ; test is targeting SP functionality, then SP need not be ; preserved if calls to subtest reinitialization ; are avoided). ; ; Branch to "fail" when any subtest fails ; Branch to "pass" when all subtests are complete ; ; Passing code is value 0xbd10 in register C. All else fails. ; ; Other than keeping a valid stack pointer across subtests, no ; subtest should make any assuptions about state changes made ; by previous subtests. For tests specifically dealing with stack ; funtionality, the use of the function calls within this template ; may be avoided. ; ; TODO: Test description here ; #ifndef COMPOSED _start: ld.16 a,0x7000 ; Set up stack pointer copy sp,a br _start_tests ; Go run stuff. ; Data sections to report group, test and subtest number test_group: defb 0x61 ; test_num: defb 0x04 ; subtest: defb 0x00 ; Set at beginnning of each subtest ; Literal section for useful memory constants (should not be modified) MEM0x00_8: defb 0x00 MEM0x01_8: defb 0x01 MEM0xFF_8: defb 0xff MEM0x0000_16: defw 0x0000 MEM0x0001_16: defw 0x0001 MEM0xFFFF_16: defw 0xffff MEM0x7F_8: defb 0x7f MEM0x80_8: defb 0x80 MEM0x7FFF_16: defw 0x7fff MEM0x8000_16: defw 0x8000 ; Optional subtest initialization init_subtest: ld.16 a,0xdead ld.16 b,0xdead ld.16 c,0xdead copy dp,a pop pc _start_tests: #endif ; Begin test here ; First, set subtest number ld.16 a,1 ld.16 b,subtest st.8 0(B),a ; verify subtest number ld.16 b,subtest ld.8 a,0x52 ld.8 a,0(B) cmpb.ne.8 a,1,fail ; Put garbage in genregs ld.16 a,0x2456 ld.16 b,0x5435 ld.16 c,0x6652 copy dp,a ld.16 a,0x6582 ; Verify stack pointer copy a,sp cmpb.ne.16 a,0x7000,fail ; Next, initialize register state for test call init_subtest ; Verify initialization cmpb.ne.16 a,0xdead,fail ; Verify stack pointer again copy a,sp cmpb.ne.16 a,0x7000,fail ld.16 a,0xdead cmpb.ne.16 a,b,fail push c pop b cmpb.ne.16 a,b,fail push dp pop b cmpb.ne.16 a,b,fail ; Verify memory initialization ld.16 b,MEM0x00_8 ld.8 a,0(B) cmpb.ne.8 a,0x00,fail ld.16 b,MEM0x01_8 ld.8 a,0(B) cmpb.ne.8 a,0x01,fail ld.16 b,MEM0xFF_8 ld.8 a,0(B) cmpb.ne.8 a,0xff,fail br hop pass: ld.16 c,0xbd10 fail: halt hop: ld.16 b,MEM0x0000_16 ld.16 a,0(B) cmpb.ne.16 a,0x0000,fail ld.16 b,MEM0x0001_16 ld.16 a,0(B) cmpb.ne.16 a,0x0001,fail ld.16 b,MEM0xFFFF_16 ld.16 a,0(B) cmpb.ne.16 a,0xffff,fail ld.16 b,MEM0x7F_8 ld.8 a,0(B) cmpb.ne.8 a,0x7f,fail ld.16 b,MEM0x80_8 ld.8 a,0(B) cmpb.ne.8 a,0x80,fail ld.16 b,MEM0x7FFF_16 ld.16 a,0(B) cmpb.ne.16 a,0x7fff,fail ld.16 b,MEM0x8000_16 ld.16 a,0(B) cmpb.ne.16 a,0x8000,fail ; That's all folks! br pass