English Amiga Board


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

 
 
Thread Tools
Old 05 November 2021, 13:21   #1
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Address register indirect with displacement, questions

I'm writing a bunch of code which I want to mix and match with assembler, plain 68K, no 020+ stuff.

I want to allocate a 64K block of memory and use it with (x, Dy, Az) addressing mode. Pretty much, I'm using this as an object pool, linking up hundreds of tiny bits of data using offsets into this pool rather than full addresses.

I understand that the value in Dy is a signed 16 bit value, -32k to 32k-1, $8000 to $7fff, so I need Az to point to the middle of the allocated memory.

But then, I want to also use a zero value in Dy as a "null pointer" equivalent, to terminate my linked up structures.

Is there a smart way to be able to access that whole 64K of data while having Dy = 0 not point to somewhere within that data, which will cause problems as I allocate objects from this pool?
deimos is offline  
Old 05 November 2021, 14:14   #2
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
That depends what you call (x, Dy, Az). There is nothing like that.
But you could mean x(Az,Dy.w). Or, with 020 syntax, (x,Az,Dy.w).
In that case, use x(Az,Dy.l) and you're done. No need to point in the middle of the area. The range for Dy would then be 1-$10000, with 0 being the special value.
And yes, always specify a size where there is one.
However, it's not what's called address register indirect with displacement, which is val(An) or (val,An).
meynaf is offline  
Old 05 November 2021, 14:36   #3
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by meynaf View Post
That depends what you call (x, Dy, Az). There is nothing like that.
But you could mean x(Az,Dy.w). Or, with 020 syntax, (x,Az,Dy.w).
In that case, use x(Az,Dy.l) and you're done. No need to point in the middle of the area. The range for Dy would then be 1-$10000, with 0 being the special value.
And yes, always specify a size where there is one.
However, it's not what's called address register indirect with displacement, which is val(An) or (val,An).
Yes, that is what I mean.

Regarding using x(Az,Dy.l) instead of x(Az,Dy.w), assuming I want to store my offsets as 16 bit words, should I just treat them as unsigned and in the assembly code just make sure the top half of Dy is cleared?
deimos is offline  
Old 05 November 2021, 14:47   #4
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
Quote:
Originally Posted by deimos View Post
Yes, that is what I mean.

Regarding using x(Az,Dy.l) instead of x(Az,Dy.w), assuming I want to store my offsets as 16 bit words, should I just treat them as unsigned and in the assembly code just make sure the top half of Dy is cleared?

yes!
jotd is offline  
Old 05 November 2021, 14:59   #5
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by jotd View Post
yes!
Ok, then that is what I shall do.

It would be neat if there was a way to do it without that though, I'd imagined there would be a way to let the numbers wrap around somehow. Nevermind.
deimos is offline  
Old 05 November 2021, 15:12   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
works with D0.W until $7FFF. to clear upper word I use

Code:
 swap d0
 clr.w  d0
 swap d0
I think it's the fastest way.
jotd is offline  
Old 05 November 2021, 15:26   #7
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by jotd View Post
I think it's the fastest way.
I don't know for 68000, but for 020+ it's not. Fastest way (in that case) is :
Code:
 andi.l #$ffff,d0
But that's when your data is already in the register. As it has to come from somewhere (d1 in the code below), the fastest way is :
Code:
 moveq #0,d0
 move.w d1,d0
meynaf is offline  
Old 05 November 2021, 15:40   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
good to know that AND FFFF is faster. I'll change that in my existing codes.
jotd is offline  
Old 05 November 2021, 15:46   #9
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
For that particular purpose I use 64KB aligned tables, for example:
Code:
	moveq	#table>>16,d0
	swap	d0
...
	move.w	(a0)+,d0
	move.l	d0,a1
	move.w	(a1),d0
This saves 2 cycles (6 for indexed vs. 4 for reg move).
Does not work with movem (it wipes out the upper half), but with 1-3 registers it's as fast or faster than movem. Also keep in mind that d0 is interpreted as unsigned (0 to 65535, and not as -32768 to 32767).
a/b is online now  
Old 05 November 2021, 16:16   #10
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 178
Quote:
Originally Posted by meynaf View Post
I don't know for 68000, but for 020+ it's not.
for 68k the swap is faster
Code:
swap d0    = 4 cycles
clr.w  d0  = 4 cycles
swap d0    = 4 cycles 

           = 12 cycles
vs.
Code:
andi.l #$ffff,d0  = 16 cycles
JoeJoe is offline  
Old 05 November 2021, 16:38   #11
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
I'll just assign my UWORD offset to a ULONG and let the compiler sort it out.
deimos 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
I got fooled by address register word size operations mr.spiv Coders. Asm / Hardware 18 05 August 2021 14:00
Problem with AsmOne Adress Register Indirect Fireball Coders. Asm / Hardware 4 27 November 2019 21:54
Address register indirect, word vs long deimos Coders. Asm / Hardware 4 15 November 2019 16:58
Address register expected Nightfox Coders. Asm / Hardware 4 12 August 2016 11:51
WinUAE Debugger - Address Register Watchpoints SparkyNZ Coders. Asm / Hardware 3 16 June 2015 22:39

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 19:46.

Top

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