Home | History | Annotate | Line # | Download | only in bfin
      1 # Blackfin testcase for loop counter values when jumping out from the last insn
      2 # mach: bfin
      3 
      4 .include "testutils.inc"
      5 	start
      6 
      7 	init_r_regs 0;
      8 	ASTAT = R0;
      9 
     10 	loadsym r1, dest;
     11 	r0 = r1;
     12 	loadsym r1, src;
     13 	r2 = 0x10;
     14 
     15 _strncpy:
     16 	CC = R2 == 0;
     17 	if CC JUMP 4f;
     18 
     19 	P2 = R2 ;       /* size */
     20 	P0 = R0 ;       /* dst*/
     21 	P1 = R1 ;       /* src*/
     22 
     23 	LSETUP (1f, 2f) LC0 = P2;
     24 1:
     25 	R1 = B [P1++] (Z);
     26 	B [P0++] = R1;
     27 	CC = R1 == 0;
     28 2:
     29 	if CC jump 3f;
     30 
     31 	fail
     32 
     33 	/* if src is shorter than n, we need to null pad bytes in dest
     34 	 * but, we can get here when the last byte is zero, and we don't
     35 	 * want to copy an extra byte at the end, so we need to check
     36 	 */
     37 3:
     38 	R2 = LC0;
     39 	CHECKREG R2, 0x0a;
     40 
     41 	CC = R2
     42 	if ! CC jump 4f;
     43 
     44 	LSETUP(5f, 5f) LC0;
     45 5:
     46 	B [P0++] = R1;
     47 
     48 4:
     49 	loadsym P1, answer;
     50 	P0 = R0;
     51 	p2 = 0x20;
     52 	LSETUP (6f, 7f) LC0 = P2;
     53 6:
     54 	R1 = B [P0++];
     55 	R2 = B [P1++];
     56 	CC = R1 == R2
     57 	IF ! CC JUMP wrong;
     58 7:
     59 	NOP;
     60 
     61 	pass
     62 
     63 wrong:
     64 	fail
     65 
     66 	.data
     67 dest:
     68 	.db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
     69 	.db 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
     70 
     71 src:
     72 	.db 0x21, 0x22, 0x23, 0x24, 0x25, 0x00, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30
     73 
     74 answer:
     75 	.db 0x21, 0x22, 0x23, 0x24, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     76 	.db 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
     77