[hatari-devel] DSP Mandelbrot bug |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hello Hatari Community,
i am experiencing a hard to find DSP bug here with Previous. Luckily it can be made "visible" using NeXTstep's included Mandelbrot demo. It might also be responsible for some distorted audio in other applications.
I appended a screenshot of the mandelbrot application where the effect of the bug is clearly visible. I pointed to one failing pixel. I also appended some debugging output containing the calculation of the failing pixel and one pixel before and one after the failing one. The last file i appended contains an overview about the variables during calculation to get a better overview.
Short overview on the calculation:
Every pixel is calculated separately. The visible pixel color is derived from the remaining loop count of some calculation. The higher the remaining count, the lower is the output value of the function. The loop exits using a jec instruction (check extension bit, exit if false).
For the "good" pixels it exits after the second run, because the upper 9 bits of b are no longer all 0. For the "bad" pixel it does not exit, because these bits are still all 0. The most suspect part of the calculation seems to be mpy +x0,x0,a at p:0097. The value of a after the third call of that instruction seems to not fit into the pattern.
Can someone with more DSP experience see the bug? It might or might not be in dsp_mul56.
Any help is greatly appreciated!
Andreas
p:008f - p:0094: setup
x0:
0x2bd70a (+ 0x51ec)
0x2c28f6 (+ 0x51eb)
0x2c7ae1
x1:
0x2bd70a
0x2c28f6
0x2c7ae1
a:
00:2bd70a:000000
00:2c28f6:000000
00:2c7ae1:000000
y0:
0x20f5c3
0x20f5c3
0x20f5c3
y1:
0x20f5c3
0x20f5c3
0x20f5c3
b:
00:20f5c3:000000
00:20f5c3:000000
00:20f5c3:000000
sp:
04
04
04
ssh:
96
96
96
ssl:
8050
8050
8050
la:
00a7
00a7
00a7
lc:
0003
0003
0003
do:
p:0096: mpy +y0,y0,b a,x0:
x0: ==, 38e55f, ff13b5
x0: ==, 39a7ef, fff376
x0: ==, 3a6b4f, 00d874
b: 00:087cb9:5da512, 00:2fabf8:5b9408, 00:7ffffe:000002
b: 00:087cb9:5da512, 00:30132d:154082, 00:7ffffe:000002
b: 00:087cb9:5da512, 00:307acf:d30702, 00:7ffffe:000002
sr: ==, ==, 8040
sr: ==, ==, 8040
sr: ==, ==, 8041
p:0097: mpy +x0,x0,a:
a: 00:0f03e3:fb98c8, 00:194a4e:263282, 00:0001b4:34bbf2
a: 00:0f3c36:3b98c8, 00:19f86d:2f6242, 00:000001:3a74c8
a: 00:0f74f0:a67382, 00:1aa999:8e44c2, 00:00016e:07e920
sr: ==, ==, 8050
sr: ==, ==, 8050
sr: ==, ==, 8051
p:0098: add a,b:
b: 00:17809d:593dda, 00:48f646:81c68a, 00:8001b2:34bbf4
b: 00:17b8ef:993dda, 00:4a0b9a:44a2c4, 00:7fffff:3a74ca
b: 00:17f1aa:041894, 00:4b2469:614bc4, 00:80016c:07e922
sr: ==, 8040, 8060
sr: ==, 8040, 8040
sr: ==, 8040, 8060
p:0099: jec p:$00a1:
true, true, false --> enddo
true, true, true
true, true, false --> enddo
p:00a1: mpy +y0,x0,b:
b: 00:0b49ee:e2bd3c, 00:22b8e1:dd4f84
b: 00:0b5f07:2d42c4, 00:2355a0:579062, ff:fff376:001914
b: 00:0b741f:35dcc6, 00:23f3de:e304e2
p:00a2: asl b:
b: 00:1693dd:c57a78, 00:4571c3:ba9f08
b: 00:16be0e:5a8588, 00:46ab40:af20c4, ff:ffe6ec:003228
b: 00:16e83e:6bb98c, 00:47e7bd:c609c4
p:00a3: asl b:
b: 00:2d27bb:8af4f0, 00:8ae387:753e10
b: 00:2d7c1c:b50b10, 00:8d5681:5e4188, ff:ffcdd8:006450
b: 00:2dd07c:d77318, 00:8fcf7b:8c1388
p:00a4: add y1,b:
b: 00:4e1d7e:8af4f0, 00:abd94a:753e10
b: 00:4e71df:b50b10, 00:ae4c44:5e4188, 00:20c39b:006450
b: 00:4ec63f:d77318, 00:b0c53e:8c1388
p:00a5: mac -y0,y0,a b,y0
y0: 4e1d7e, 7fffff
y0: 4e71df, 7fffff, 20c39b
y0: 4ec63f, 7fffff
a: 00:06872a:9df3b6, ff:e99e55:ca9e7a
a: 00:06bf7c:ddf3b6, ff:e9e540:1a21c0, ff:800003:3a74c6
a: 00:06f837:48ce70, ff:ea2ec9:bb3dc0
p:00a6: asl a:
a: 00:0d0e55:3be76c, ff:d33cab:953cf4
a: 00:0d7ef9:bbe76c, ff:d3ca80:344380, ff:000006:74e98c
a: 00:0df06e:919ce0, ff:d45d93:767b80
p:00a7: add x1,a:
a: 00:38e55f:3be76c, ff:ff13b5:953cf4
a: 00:39a7ef:bbe76c, ff:fff376:344380, ff:2c28fc:74e98c
a: 00:3a6b4f:919ce0, 00:00d874:767b80
loop back --> p:0096 (or continue at p:00a8 if loop counter 0)
Mem: x:0x31cc 0x000002 -> 0x000002
p:008f 44d900 (02 cyc) move x:(r1)+,x0
Reg: x0 $000001 -> $2bd70a
Reg: r1 $2a9a -> $2a9b
p:0090 46d100 (02 cyc) move x:(r1)-,y0
Reg: y0 $7fffff -> $20f5c3
Reg: r1 $2a9b -> $2a9a
p:0091 044911 (04 cyc) lua (r1)+n1,r1
Reg: r1 $2a9a -> $2a9c
p:0092 208541 (02 cyc) tfr x0,a x0,x1
Reg: x1 $2b851f -> $2bd70a
Reg: a $00:000002:000000 -> $00:2bd70a:000000
p:0093 20c759 (02 cyc) tfr y0,b y0,y1
Reg: b $00:80064e:53e34a -> $00:20f5c3:000000
p:0094 06d500 0000a7 (06 cyc) do r5,p:$00a7
Reg: sp $02 -> $04
Reg: ssh $8f -> $96
Reg: ssl $10 -> $8050
Reg: la $00a9 -> $00a7
Reg: lc $00f3 -> $0003
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: b $00:20f5c3:000000 -> $00:087cb9:5da512
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:2bd70a:000000 -> $00:0f03e3:fb98c8
p:0098 200018 (02 cyc) add a,b
Reg: b $00:087cb9:5da512 -> $00:17809d:593dda
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:17809d:593dda -> $00:0b49ee:e2bd3c
p:00a2 20003a (02 cyc) asl b
Reg: b $00:0b49ee:e2bd3c -> $00:1693dd:c57a78
p:00a3 20003a (02 cyc) asl b
Reg: b $00:1693dd:c57a78 -> $00:2d27bb:8af4f0
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:2d27bb:8af4f0 -> $00:4e1d7e:8af4f0
Reg: sr $8050 -> $8040
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $20f5c3 -> $4e1d7e
Reg: a $00:0f03e3:fb98c8 -> $00:06872a:9df3b6
Reg: sr $8040 -> $8050
p:00a6 200032 (02 cyc) asl a
Reg: a $00:06872a:9df3b6 -> $00:0d0e55:3be76c
p:00a7 200060 (02 cyc) add x1,a
Reg: a $00:0d0e55:3be76c -> $00:38e55f:3be76c
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $2bd70a -> $38e55f
Reg: b $00:4e1d7e:8af4f0 -> $00:2fabf8:5b9408
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:38e55f:3be76c -> $00:194a4e:263282
p:0098 200018 (02 cyc) add a,b
Reg: b $00:2fabf8:5b9408 -> $00:48f646:81c68a
Reg: sr $8050 -> $8040
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:48f646:81c68a -> $00:22b8e1:dd4f84
Reg: sr $8040 -> $8050
p:00a2 20003a (02 cyc) asl b
Reg: b $00:22b8e1:dd4f84 -> $00:4571c3:ba9f08
Reg: sr $8050 -> $8040
p:00a3 20003a (02 cyc) asl b
Reg: b $00:4571c3:ba9f08 -> $00:8ae387:753e10
Reg: sr $8040 -> $8060
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:8ae387:753e10 -> $00:abd94a:753e10
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $4e1d7e -> $7fffff
Reg: a $00:194a4e:263282 -> $ff:e99e55:ca9e7a
Reg: sr $8060 -> $8058
p:00a6 200032 (02 cyc) asl a
Reg: a $ff:e99e55:ca9e7a -> $ff:d33cab:953cf4
Reg: sr $8058 -> $8059
p:00a7 200060 (02 cyc) add x1,a
Reg: a $ff:d33cab:953cf4 -> $ff:ff13b5:953cf4
Reg: sr $8059 -> $8058
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $38e55f -> $ff13b5
Reg: b $00:abd94a:753e10 -> $00:7ffffe:000002
Reg: sr $8058 -> $8040
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $ff:ff13b5:953cf4 -> $00:0001b4:34bbf2
Reg: sr $8040 -> $8050
p:0098 200018 (02 cyc) add a,b
Reg: b $00:7ffffe:000002 -> $00:8001b2:34bbf4
Reg: sr $8050 -> $8060
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:009b 22ae00 (02 cyc) move r5,a
Reg: a $00:0001b4:34bbf2 -> $00:000003:000000
p:009c 0444bf (02 cyc) movec lc,x0
Reg: x0 $ff13b5 -> $000001
p:009d 200044 (02 cyc) sub x0,a
Reg: a $00:000003:000000 -> $00:000002:000000
Reg: sr $8060 -> $8050
p:009e 00008c (02 cyc) enddo
Reg: sp $04 -> $02
Reg: ssh $96 -> $8f
Reg: ssl $8050 -> $10
Reg: la $00a7 -> $00a9
Reg: lc $0001 -> $00f3
p:009f 0af080 0000a9 (06 cyc) jmp p:$00a9
p:00a9 564e00 (02 cyc) move a,x:(r6)+n6
Reg: r6 $31cd -> $31ce
Mem: x:0x31cd 0x000002 -> 0x000002
p:008f 44d900 (02 cyc) move x:(r1)+,x0
Reg: x0 $000001 -> $2c28f6
Reg: r1 $2a9c -> $2a9d
p:0090 46d100 (02 cyc) move x:(r1)-,y0
Reg: y0 $7fffff -> $20f5c3
Reg: r1 $2a9d -> $2a9c
p:0091 044911 (04 cyc) lua (r1)+n1,r1
Reg: r1 $2a9c -> $2a9e
p:0092 208541 (02 cyc) tfr x0,a x0,x1
Reg: x1 $2bd70a -> $2c28f6
Reg: a $00:000002:000000 -> $00:2c28f6:000000
p:0093 20c759 (02 cyc) tfr y0,b y0,y1
Reg: b $00:8001b2:34bbf4 -> $00:20f5c3:000000
p:0094 06d500 0000a7 (06 cyc) do r5,p:$00a7
Reg: sp $02 -> $04
Reg: ssh $8f -> $96
Reg: ssl $10 -> $8050
Reg: la $00a9 -> $00a7
Reg: lc $00f2 -> $0003
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: b $00:20f5c3:000000 -> $00:087cb9:5da512
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:2c28f6:000000 -> $00:0f3c36:3b98c8
p:0098 200018 (02 cyc) add a,b
Reg: b $00:087cb9:5da512 -> $00:17b8ef:993dda
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:17b8ef:993dda -> $00:0b5f07:2d42c4
p:00a2 20003a (02 cyc) asl b
Reg: b $00:0b5f07:2d42c4 -> $00:16be0e:5a8588
p:00a3 20003a (02 cyc) asl b
Reg: b $00:16be0e:5a8588 -> $00:2d7c1c:b50b10
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:2d7c1c:b50b10 -> $00:4e71df:b50b10
Reg: sr $8050 -> $8040
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $20f5c3 -> $4e71df
Reg: a $00:0f3c36:3b98c8 -> $00:06bf7c:ddf3b6
Reg: sr $8040 -> $8050
p:00a6 200032 (02 cyc) asl a
Reg: a $00:06bf7c:ddf3b6 -> $00:0d7ef9:bbe76c
p:00a7 200060 (02 cyc) add x1,a
Reg: a $00:0d7ef9:bbe76c -> $00:39a7ef:bbe76c
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $2c28f6 -> $39a7ef
Reg: b $00:4e71df:b50b10 -> $00:30132d:154082
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:39a7ef:bbe76c -> $00:19f86d:2f6242
p:0098 200018 (02 cyc) add a,b
Reg: b $00:30132d:154082 -> $00:4a0b9a:44a2c4
Reg: sr $8050 -> $8040
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:4a0b9a:44a2c4 -> $00:2355a0:579062
Reg: sr $8040 -> $8050
p:00a2 20003a (02 cyc) asl b
Reg: b $00:2355a0:579062 -> $00:46ab40:af20c4
Reg: sr $8050 -> $8040
p:00a3 20003a (02 cyc) asl b
Reg: b $00:46ab40:af20c4 -> $00:8d5681:5e4188
Reg: sr $8040 -> $8060
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:8d5681:5e4188 -> $00:ae4c44:5e4188
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $4e71df -> $7fffff
Reg: a $00:19f86d:2f6242 -> $ff:e9e540:1a21c0
Reg: sr $8060 -> $8058
p:00a6 200032 (02 cyc) asl a
Reg: a $ff:e9e540:1a21c0 -> $ff:d3ca80:344380
Reg: sr $8058 -> $8059
p:00a7 200060 (02 cyc) add x1,a
Reg: a $ff:d3ca80:344380 -> $ff:fff376:344380
Reg: sr $8059 -> $8058
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $39a7ef -> $fff376
Reg: b $00:ae4c44:5e4188 -> $00:7ffffe:000002
Reg: sr $8058 -> $8040
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $ff:fff376:344380 -> $00:000001:3a74c8
Reg: sr $8040 -> $8050
p:0098 200018 (02 cyc) add a,b
Reg: b $00:7ffffe:000002 -> $00:7fffff:3a74ca
Reg: sr $8050 -> $8040
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:7fffff:3a74ca -> $ff:fff376:001914
Reg: sr $8040 -> $8058
p:00a2 20003a (02 cyc) asl b
Reg: b $ff:fff376:001914 -> $ff:ffe6ec:003228
Reg: sr $8058 -> $8059
p:00a3 20003a (02 cyc) asl b
Reg: b $ff:ffe6ec:003228 -> $ff:ffcdd8:006450
p:00a4 200078 (02 cyc) add y1,b
Reg: b $ff:ffcdd8:006450 -> $00:20c39b:006450
Reg: sr $8059 -> $8051
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $7fffff -> $20c39b
Reg: a $00:000001:3a74c8 -> $ff:800003:3a74c6
Reg: sr $8051 -> $8049
p:00a6 200032 (02 cyc) asl a
Reg: a $ff:800003:3a74c6 -> $ff:000006:74e98c
Reg: sr $8049 -> $8079
p:00a7 200060 (02 cyc) add x1,a
Reg: a $ff:000006:74e98c -> $ff:2c28fc:74e98c
Reg: sr $8079 -> $8078
p:00a8 22ae00 (02 cyc) move r5,a
Reg: a $ff:2c28fc:74e98c -> $00:000003:000000
p:00a9 564e00 (02 cyc) move a,x:(r6)+n6
Reg: r6 $31ce -> $31cf
Mem: x:0x31ce 0x000002 -> 0x000003
p:008f 44d900 (02 cyc) move x:(r1)+,x0
Reg: x0 $fff376 -> $2c7ae1
Reg: r1 $2a9e -> $2a9f
p:0090 46d100 (02 cyc) move x:(r1)-,y0
Reg: y0 $20c39b -> $20f5c3
Reg: r1 $2a9f -> $2a9e
p:0091 044911 (04 cyc) lua (r1)+n1,r1
Reg: r1 $2a9e -> $2aa0
p:0092 208541 (02 cyc) tfr x0,a x0,x1
Reg: x1 $2c28f6 -> $2c7ae1
Reg: a $00:000003:000000 -> $00:2c7ae1:000000
p:0093 20c759 (02 cyc) tfr y0,b y0,y1
Reg: b $00:20c39b:006450 -> $00:20f5c3:000000
p:0094 06d500 0000a7 (06 cyc) do r5,p:$00a7
Reg: sp $02 -> $04
Reg: ssh $8f -> $96
Reg: ssl $10 -> $8078
Reg: la $00a9 -> $00a7
Reg: lc $00f1 -> $0003
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: b $00:20f5c3:000000 -> $00:087cb9:5da512
Reg: sr $8078 -> $8050
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:2c7ae1:000000 -> $00:0f74f0:a67382
p:0098 200018 (02 cyc) add a,b
Reg: b $00:087cb9:5da512 -> $00:17f1aa:041894
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:17f1aa:041894 -> $00:0b741f:35dcc6
p:00a2 20003a (02 cyc) asl b
Reg: b $00:0b741f:35dcc6 -> $00:16e83e:6bb98c
p:00a3 20003a (02 cyc) asl b
Reg: b $00:16e83e:6bb98c -> $00:2dd07c:d77318
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:2dd07c:d77318 -> $00:4ec63f:d77318
Reg: sr $8050 -> $8040
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $20f5c3 -> $4ec63f
Reg: a $00:0f74f0:a67382 -> $00:06f837:48ce70
Reg: sr $8040 -> $8050
p:00a6 200032 (02 cyc) asl a
Reg: a $00:06f837:48ce70 -> $00:0df06e:919ce0
p:00a7 200060 (02 cyc) add x1,a
Reg: a $00:0df06e:919ce0 -> $00:3a6b4f:919ce0
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $2c7ae1 -> $3a6b4f
Reg: b $00:4ec63f:d77318 -> $00:307acf:d30702
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:3a6b4f:919ce0 -> $00:1aa999:8e44c2
p:0098 200018 (02 cyc) add a,b
Reg: b $00:307acf:d30702 -> $00:4b2469:614bc4
Reg: sr $8050 -> $8040
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:00a1 2000d8 (02 cyc) mpy +y0,x0,b
Reg: b $00:4b2469:614bc4 -> $00:23f3de:e304e2
Reg: sr $8040 -> $8050
p:00a2 20003a (02 cyc) asl b
Reg: b $00:23f3de:e304e2 -> $00:47e7bd:c609c4
Reg: sr $8050 -> $8040
p:00a3 20003a (02 cyc) asl b
Reg: b $00:47e7bd:c609c4 -> $00:8fcf7b:8c1388
Reg: sr $8040 -> $8060
p:00a4 200078 (02 cyc) add y1,b
Reg: b $00:8fcf7b:8c1388 -> $00:b0c53e:8c1388
p:00a5 21e696 (02 cyc) mac -y0,y0,a b,y0
Reg: y0 $4ec63f -> $7fffff
Reg: a $00:1aa999:8e44c2 -> $ff:ea2ec9:bb3dc0
Reg: sr $8060 -> $8058
p:00a6 200032 (02 cyc) asl a
Reg: a $ff:ea2ec9:bb3dc0 -> $ff:d45d93:767b80
Reg: sr $8058 -> $8059
p:00a7 200060 (02 cyc) add x1,a
Reg: a $ff:d45d93:767b80 -> $00:00d874:767b80
Reg: sr $8059 -> $8051
p:0096 21c498 (02 cyc) mpy +y0,y0,b a,x0
Reg: x0 $3a6b4f -> $00d874
Reg: b $00:b0c53e:8c1388 -> $00:7ffffe:000002
Reg: sr $8051 -> $8041
p:0097 200080 (02 cyc) mpy +x0,x0,a
Reg: a $00:00d874:767b80 -> $00:00016e:07e920
Reg: sr $8041 -> $8051
p:0098 200018 (02 cyc) add a,b
Reg: b $00:7ffffe:000002 -> $00:80016c:07e922
Reg: sr $8051 -> $8060
p:0099 0af0a5 0000a1 (06 cyc) jec p:$00a1
p:009b 22ae00 (02 cyc) move r5,a
Reg: a $00:00016e:07e920 -> $00:000003:000000
p:009c 0444bf (02 cyc) movec lc,x0
Reg: x0 $00d874 -> $000001
p:009d 200044 (02 cyc) sub x0,a
Reg: a $00:000003:000000 -> $00:000002:000000
Reg: sr $8060 -> $8050
p:009e 00008c (02 cyc) enddo
Reg: sp $04 -> $02
Reg: ssh $96 -> $8f
Reg: ssl $8078 -> $10
Reg: la $00a7 -> $00a9
Reg: lc $0001 -> $00f1
p:009f 0af080 0000a9 (06 cyc) jmp p:$00a9
p:00a9 564e00 (02 cyc) move a,x:(r6)+n6
Reg: r6 $31cf -> $31d0
Mem: x:0x31cf 0x000002 -> 0x000002