From 524d770c9c127e077f59f0b2adadc9c14d003e0a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 6 Nov 2021 13:19:35 -0400 Subject: sim: sh: fix uninitialized variable usage with pdmsb This block of code relies on i to control which bits to test and how many times to run through the loop, but it never actually initialized it. There is another chunk of code that handles the pdmsb instruction that sets i to 16, so use that here too assuming it's correct. The programming manual suggests this is the right value too, but I am by no means a SuperH DSP expert. The tests are still passing though ... --- sim/sh/gencode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 9ef8b46..80eecfd 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -2363,7 +2363,7 @@ op ppi_tab[] = }, { "","", "(if cc) pdmsb Sy,Dz", "101111cc..yyzzzz", "unsigned Sy = DSP_R (y);", - "int i;", + "int i = 16;", "", "if (Sy < 0)", " Sy = ~Sy;", -- cgit v1.1