; ###----------------------------------------------------------------### ; # file : exc012.u # ; # date : Mar 26 1996 # ; # descr. : functional test for mips # ; ###----------------------------------------------------------------### ; ###--------------------------------------------------------### ; # exceptions : # ; # - data address miss alignment (storing a half-word) # ; ###--------------------------------------------------------### adr .equ 0x40000050 data .equ 0x616b ; data .org 0x00400000 .start init init: loadi r31, back_from_exception loadi r1 , adr ; half word's address in r1 loadi r2 , data ; data in r2 loadi r3 , data ; same data in r3 loadi r4 , data ^ 0xffffffff ; complemented data in r4 ; ###--------------------------------------------------------### ; # store the word to initialize the memory location # ; ###--------------------------------------------------------### sw r2, 0 (r1 ) ; ###--------------------------------------------------------### ; # store half-word at a miss aligned address # ; ###--------------------------------------------------------### sh r4, 1 (r1 ) ; EXCEPTION (alignment) ; ###--------------------------------------------------------### ; # after returning from exception, read the memory # ; # location and check that the faulty store word has not # ; # modified the memory # ; ###--------------------------------------------------------### back_from_exception: lw r5 , 0 (r1 ) ; ###--------------------------------------------------------### ; # if the read word is correct branch to good # ; ###--------------------------------------------------------### bne r5, r3,bad nop j good nop .org 0x004000d0 good: j good nop bad: j bad nop .end