/*
 * Test_015
 *
 * end_ko : infinite_loop
 * end_ok : Write in R1 the stop address and stop an data
 *          The store in the destination of an jump
 * start  : Test l.bf
 */
	
	.file	"crt0.s"
	/*
	.section .vector
	*/
	.section .text
	.align	4	

/* ---[ 0x0  : Print a error ]------------------------------------------- */

	.org 0x0
_end_ko        :        
	l.movhi r1,     hi(_tty)
	l.ori   r1, r1, lo(_tty)
        l.sw    4(r1), r1 /* stop address */
_infinite_loop :        
        l.j	_infinite_loop
        l.nop

_end_ok :
	l.movhi r1,     hi(_tty)
	l.ori   r1, r1, lo(_tty)
        l.sw    4(r1), r0 /* stop address */


/* ---[ 0x100: RESET exception ]----------------------------------------- */
        .org 0x100
	.global _start
_start:

	l.movhi r2,     hi(0x00000010) /* count max */
	l.ori   r2, r2, lo(0x00000100)
        
        /**********/
        /* Test 1 */
        /**********/
        
	l.movhi r1,     hi(0x00000000) /* RA */
	l.ori   r1, r1, lo(0x00000000)
        
        /* Test result */
_test_1_loop :
        l.sfne  r1, r2
        l.bf    _test_1_loop
        l.addi  r1, r1, 1
_test_1_end :

        /**********/
        /* Test 2 */
        /**********/
        
	l.movhi r1,     hi(0x00000000) /* RA */
	l.ori   r1, r1, lo(0x00000000)
        
        /* Test result */
_test_2_loop :
        l.sfeq  r1, r2
        l.bf    _test_2_end
        l.addi  r1, r1, 1
        l.j     _test_2_loop
        l.nop   
_test_2_end :
        
        
        /**********/
        /* End */
        /**********/

        l.j     _end_ok
        l.nop
