;
;   Bit field test.  Should never hit the "err" label case.  At the end of
;   execution, R0 should contains 0000020C.  Tests correct execution of
;   bit field test-and-set instructions, for positions within first byte
;   and within other bytes of register or memory file.
;
;   NOTE:   This test should be rerun as soon as VM is available, because
;           the memory version of emul_bbstate() must be made VM aware to
;           do bit field addressing.
;

        .print      "BIT.ASM Bit test/set stream"
        .print      "At end of test, R0 = 020C, R1 = 0255, R2 = 020C"
        .print
        
        .base       200
        
main:   movl        #5, r0              ; Bit pattern 0000 0101 in low byte
        bbss        #1, r0, err         ; Should fail branch, but set R0 to 0x07
        bbss        #9, r0, err         ; Should set R0 to 0x0207
        bbsc        #1, r0, ok1         ; Should branch, R0 to 0x0205
        brb         err

ok1:    bbcs        #3, r0, ok2         ; Should branch, R0 to 0x020D
        brb         err

ok2:    bbcc        #1, r0, ok3         ; Should branch, R0 to 0x020D
        brb         err

ok3:    bbcc        #0, r0, err         ; Should not branch, R0 to 0x020C
        brb         mtest               ; Go to in-memory tests
        
err:    halt

mtest:  nop
    
        moval       @#data, r1          ; Start same test sequence gain, but this
                                        ;   time use a memory location instead of a
                                        ;   register.
        movl        #5, (r1)            ; Initialize the data value (in case of rerun)
        bbss        #1, (r1), err       ; Should fail branch, but set data to 0x071
        bbss        #9, (r1), err       ; Should set data to 0x0207
        bbsc        #1, (r1), mok1      ; Should branch, data to 0x0205
        brb         err

mok1:   bbcs        #3, (r1), mok2      ; Should branch, data to 0x020D
        brb         err

mok2:   bbcc        #1, (r1), mok3      ; Should branch, data to 0x020D
        brb         err

mok3:   bbcc        #0, (r1), err       ; Should not branch, data to 0x020C
        movl        @#data, r2          ; Get value in register at end
        halt                            ; all done

data:   .long       0                   ; Memory datum we modify located here.
        



