English Amiga Board


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

 
 
Thread Tools
Old 15 July 2020, 02:40   #1
Auscoder
Registered User
 
Join Date: Jan 2019
Location: Brisbane
Posts: 99
68020 Data registers as addresses? (VASM?)

Mentioned here : http://jvaltane.kapsi.fi/amiga/howto...0x0issues.html

Quote:
Data registers can be used as addresses. (d0) is 3 cycles slower than (a0), and it only takes 2 cycles to move a data register to an address register, but this can help in situations where there is not a free address register.
Though I have tried using a data register as an address in vasm with -m68020, and essentially the code compiles but is not working.

Code:
		move.l #x,d0		                ; Allocation bytes
		move.l #MEMF_CHIP,d1              	; CHIP Ram
		jsr    _LVOAllocMem(a6)		        ; exec -198

                move.l d0,a0
                move.l #0,0(a0) ; WORKS
                move.l #0,0(d0) ; FAILS
I guess two questions :

Is it true a data register can be used as address register on 68020+ (with penalty)?
If so, is it able to be used with said addressing mode?

Thank you!
Auscoder is offline  
Old 15 July 2020, 03:30   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yes, 020+ new adressing modes can handle that. But it doesn't quite work the same way.
Basically, the full addressing mode is ([offset,ax or pc,index*scale],displacement) and the individual parts can be suppressed. So you do that to everything except the index, which is either ax or dx, so dx in your case, and you get ([dx]).
Now what does this do? It reads a 32-bit address from memory pointed by dx (everything inside square brackets), and then adds displacement to it and it reads/writes data from/to that displaced 32-bit address. So it's kind of a double index, or in plain m68k it would be like:
Code:
  move.l offset(ax,rx*scale),tmp_areg
  move.l #0,displacement(tmp_areg)
a/b is offline  
Old 15 July 2020, 08:52   #3
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
If 0(d0) fails, try (d0.l) instead.
meynaf is offline  
Old 15 July 2020, 09:52   #4
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
works if you invoke vasm with -m68020

vasmm68k_mot -m68020 -Fhunk -o foo foo.asm
alkis is offline  
Old 15 July 2020, 11:05   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Meynaf makes an important point. d0 is the index register! So when you write 0(d0) it is really (0,za0,d0.w). The address register is assumed as a0 and suppressed. The size of the index register always defaults to Word(!). Which means the MSW from your pointer in d0 will be disregarded.
phx is offline  
Old 17 July 2020, 02:54   #6
Auscoder
Registered User
 
Join Date: Jan 2019
Location: Brisbane
Posts: 99
Thank you all,

Absolutely clear now.

Thanks a/b for the explanation on the full addressing mode. Working successfully now with suppressed or full syntax.

!! As noted by phx and meynaf d0.l is absolutely key.
Auscoder 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
Data/instruction alignment for 68020..060 phx Coders. Asm / Hardware 16 17 February 2020 20:22
VASM macros/equates for registers jotd Coders. Asm / Hardware 5 06 September 2019 18:47
log write to custom registers with out of bounds addresses jotd support.WinUAE 12 03 February 2019 13:43
vasm/mot: data structures guy lateur Coders. Asm / Hardware 10 29 December 2018 22:15
Devpac and assembling for absolute addresses h0ffman Coders. General 10 21 March 2011 19:12

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 21:27.

Top

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