diff --git a/tests/misc/head.S b/tests/misc/head.S index b0acb7f..d490a61 100644 --- a/tests/misc/head.S +++ b/tests/misc/head.S @@ -137,3 +137,28 @@ test_mtpvr: mtlr %r0 blr + +/* Test that bdnz and bdnzl update CTR and LR correctly */ + .global test_bdnzl +test_bdnzl: + mflr %r10 + mfcr %r11 + li %r0,0xf8 + mtctr %r0 + lis %r0,0x2000 + mtcr %r0 + addpcis %r9,0 +1: bdnztl 27,3f +2: bdnzt 14,4f +3: nop +4: li %r3,1 + addi %r9,%r9,2b-1b + mflr %r8 + cmpd %r8,%r9 + bne 9f + mfctr %r7 + cmpdi %r7,0xf6 + bne 9f + li %r3,0 +9: mtlr %r10 + blr diff --git a/tests/misc/misc.c b/tests/misc/misc.c index 283ca7f..73745d9 100644 --- a/tests/misc/misc.c +++ b/tests/misc/misc.c @@ -14,6 +14,7 @@ extern long test_addpcis_1(void); extern long test_addpcis_2(void); extern long test_mfpvr(void); extern long test_mtpvr(void); +extern long test_bdnzl(void); // i < 100 void print_test_number(int i) @@ -58,5 +59,12 @@ int main(void) } else puts(PASS); + print_test_number(5); + if (test_bdnzl() != 0) { + fail = 1; + puts(FAIL); + } else + puts(PASS); + return fail; } diff --git a/tests/test_misc.bin b/tests/test_misc.bin index 7e68e1c..2264686 100755 Binary files a/tests/test_misc.bin and b/tests/test_misc.bin differ diff --git a/tests/test_misc.console_out b/tests/test_misc.console_out index 2ff5a99..e59c03f 100644 --- a/tests/test_misc.console_out +++ b/tests/test_misc.console_out @@ -2,3 +2,4 @@ Test 01:PASS Test 02:PASS Test 03:PASS Test 04:PASS +Test 05:PASS