06 February 2021, 18:14 | #1 |
<optimized out>
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
|
Lookup tables and addressing modes
What's the biggest lookup table I can do and still use it efficiently with (d0, a0) style addressing?
Assuming a table of words, I think the answer is 16K table entries. This is based on the d0 part being signed, so if the table only goes up, then the max is 0x7fff, but words mean 0x3fff, which is the 16K above. But, if I'm allowed signed values, then I can go between -16K and 16K-1, right? So, if I really believe I need all that accuracy, then should I change all my code to use values of [-pi..pi) rather than [0..2pi)? But, I can't do this in C, can I? This question has come up today, twice, because the atan2 code I was thinking of using assumes pi is 16384, and returns values between 0 and 32,767 inclusive, and because converting yaw, pitch, roll to a quaternion involves half angles, so 1/2 = 0 becomes a problem. |
06 February 2021, 18:38 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,483
|
It's not a problem also if you got d0.w containing unsigned values and use 32K word entries.
Simply init a0 to [start+32768] and construct the table considering that $8000 is at a0-$8000 and on. No idea how to do it in C. |
06 February 2021, 18:45 | #3 |
<optimized out>
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
|
|
06 February 2021, 18:56 | #4 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,483
|
Quote:
In C probably full 32 bit from d0 are used (and generated code to handle this is sure slower).. Anyway, a0,d0.w and a0,d0.l execute in the same number of cycles. |
|
06 February 2021, 18:59 | #5 | |
<optimized out>
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
|
Quote:
|
|
06 February 2021, 19:36 | #6 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,024
|
|
06 February 2021, 19:39 | #7 |
<optimized out>
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
|
|
06 February 2021, 19:56 | #8 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,024
|
|
06 February 2021, 20:00 | #9 |
<optimized out>
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
|
|
06 February 2021, 20:49 | #10 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,050
|
That's why I'm so annoyed when I see (xx,ax,d0). Why do people insist on writing ambiguous and potentially buggy code and relying on assembler defaults (that may or may not work with different assemblers), and then eventually unexperienced people see that and start doing the same?
And if I see moveq.l or lea.l in the same code, it's time for painkillers. |
06 February 2021, 21:51 | #11 | |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 389
|
Quote:
When writing optmized code, it's often slightly more work to make sure the top half of the index register isn't trash. So there is some cost involved if you use a long index. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Roadshow strange DNS lookup issue wrong name and IP resolved | chocsplease | support.Apps | 1 | 19 April 2019 17:59 |
WHDLoad Game Name Lookup | Enverex | support.FS-UAE | 23 | 28 February 2015 22:21 |
Lookup by SPS ID | jotd | HOL suggestions and feedback | 2 | 02 August 2006 00:45 |
Addressing modes | BippyM | Coders. General | 17 | 03 February 2005 09:57 |
Automatic Game Database Lookup !? | AmiGer | Retrogaming General Discussion | 6 | 03 October 2002 11:30 |
|
|