English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 06 February 2021, 18:14   #1
Ernst Blofeld
<optimized out>
 
Ernst Blofeld's Avatar
 
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.
Ernst Blofeld is offline  
Old 06 February 2021, 18:38   #2
ross
Defendit numerus
 
ross's Avatar
 
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.
ross is offline  
Old 06 February 2021, 18:45   #3
Ernst Blofeld
<optimized out>
 
Ernst Blofeld's Avatar
 
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
Quote:
Originally Posted by ross View Post
No idea how to do it in C.
I can vasm in a bit of assembly, and put the label somewhere in the middle?
Ernst Blofeld is offline  
Old 06 February 2021, 18:56   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,483
Quote:
Originally Posted by Ernst Blofeld View Post
I can vasm in a bit of assembly, and put the label somewhere in the middle?
If you add vasm code there is no problem at all (you can pass directly the right address ad use the a0,d0.w addressing mode).

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.
ross is offline  
Old 06 February 2021, 18:59   #5
Ernst Blofeld
<optimized out>
 
Ernst Blofeld's Avatar
 
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
Quote:
Originally Posted by ross View Post
If you add vasm code there is no problem at all (you can pass directly the right address ad use the a0,d0.w addressing mode).

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.
There's an a0,d0.l?
Ernst Blofeld is offline  
Old 06 February 2021, 19:36   #6
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,024
Quote:
Originally Posted by Ernst Blofeld View Post
There's an a0,d0.l?
Yes, theoretical maximum table can be 4GB. Exist also a0,a1.w or a0,a1.l.
Don_Adan is offline  
Old 06 February 2021, 19:39   #7
Ernst Blofeld
<optimized out>
 
Ernst Blofeld's Avatar
 
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
Quote:
Originally Posted by Don_Adan View Post
Yes, theoretical maximum table can be 4GB. Exist also a0,a1.w or a0,a1.l.
You guys are talking 68K, not 020+, right?
Ernst Blofeld is offline  
Old 06 February 2021, 19:56   #8
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,024
Quote:
Originally Posted by Ernst Blofeld View Post
You guys are talking 68K, not 020+, right?
Yes, 68000. 4GB is theory only, because 68000 can not address more than 16MB. f.e move.b (A0,D0.L),D1 for 68000 is limited to 16MB, but for 68020+ for 4GB.
Don_Adan is offline  
Old 06 February 2021, 20:00   #9
Ernst Blofeld
<optimized out>
 
Ernst Blofeld's Avatar
 
Join Date: Sep 2020
Location: <optimized out>
Posts: 321
Quote:
Originally Posted by Don_Adan View Post
Yes, 68000. 4GB is theory only, because 68000 can not address more than 16MB. f.e move.b (A0,D0.L),D1 for 68000 is limited to 16MB, but for 68020+ for 4GB.
Right then. I wonder where my assumption that the offset was limited to word size came from.
Ernst Blofeld is offline  
Old 06 February 2021, 20:49   #10
a/b
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.
a/b is offline  
Old 06 February 2021, 21:51   #11
Jobbo
Registered User
 
Jobbo's Avatar
 
Join Date: Jun 2020
Location: Druidia
Posts: 389
Quote:
Originally Posted by Ernst Blofeld View Post
Right then. I wonder where my assumption that the offset was limited to word size came from.

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.
Jobbo is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:22.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07913 seconds with 13 queries