Re: [hatari-devel] view the DSP stack? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
On 17/02/2013 21:22, Laurent Sallafranque wrote:
Hi Doug,
Thanks a lot. I've uploaded a patch, if you can verify it.
I've also patched another instruction that I think was wrong timing :
P:ext JSR ext_addr
Maybe you can test it too with my newpatch to verify if it's OK now ?
Eero, The way I've done this patch is probably not the most optimized :
I use one variable (access_to_ext_memory) as a 3 FLAG bits variable :
- 1st bit for access to X external memory
- 2nd bit for access to Y external memory
- 3rd bit for access to P external memory
Then I have to slide the bits to count how many access I did to external
memory.
/* Add the waitstate due to external memory access */
+ /* (2 extra cycles per extra access to the external memory after the first one */
+ if (access_to_ext_memory != 0) {
+ value = access_to_ext_memory & 1;
+ value += (access_to_ext_memory & 2) >> 1;
+ value += (access_to_ext_memory & 4) >> 2;
+
+ if (value > 1)
+ dsp_core.instr_cycle += (value - 1) * 2;
+ }
+
If you think there's a more optimized way to do it, just don't hesitate
to change it.
Hello
given there're only 3 bits, this makes 8 cases, so you can store the
number of 1 bits in a small array and avoid any if/and/shift :
eg :
count_bit[8] = { 0,1,1,2,1,2,2,3 };
value = count_bit[ access_to_ext_memory ];
if (value > 1)
dsp_core.instr_cycle += (value - 1) * 2;
Or you could even store (value-1)*2 in the array and do directly
dsp_core.instr_cycles += access_to_ext_memory_penalty[access_to_ext_memory]
6 lines packed into 1, with maximum speed ;)
Nicolas