Re: [hatari-devel] view the DSP stack? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
On Sunday 17 February 2013 12: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.
>
> Best regards
>
> Laurent
>
Hi Laurent,
Here's my answer:
bit_field = access_to_ext_memory & 7;
value += (bit_field != 0); /* Increment from 0 to 3 bits */
bit_field &= bit_field - 1;
value += (bit_field != 0);
bit_field &= bit_field - 1;
value += (bit_field != 0);
value += (bit_field != 0); /* if (value > 1) {dsp_core.instr_cycle += (value - 1) * 2;} */
Also, one could increment a counter before packing
the bits into 'access_to_ext_memory'.
David