05 November 2021, 13:21 | #1 |
It's coming back!
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? |
05 November 2021, 14:14 | #2 |
son of 68k
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). |
05 November 2021, 14:36 | #3 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
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? |
|
05 November 2021, 14:47 | #4 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
|
05 November 2021, 14:59 | #5 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
05 November 2021, 15:12 | #6 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
works with D0.W until $7FFF. to clear upper word I use
Code:
swap d0 clr.w d0 swap d0 |
05 November 2021, 15:26 | #7 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I don't know for 68000, but for 020+ it's not. Fastest way (in that case) is :
Code:
andi.l #$ffff,d0 Code:
moveq #0,d0 move.w d1,d0 |
05 November 2021, 15:40 | #8 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
good to know that AND FFFF is faster. I'll change that in my existing codes.
|
05 November 2021, 15:46 | #9 |
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 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). |
05 November 2021, 16:16 | #10 |
Registered User
Join Date: Feb 2020
Location: Germany
Posts: 178
|
|
05 November 2021, 16:38 | #11 |
It's coming back!
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.
|
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 |
|
|