English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 24 January 2005, 18:20   #1
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
Addressing modes

Could some nice chappy explain to me (in English) the following: Adressing Modes

I know what they are called

Inherant
Regiser
Immediate
Absolute
Address Register Indirect
Address Register Indirect with displacement
Address Register Indirect with postincrement
Address Register Indirect with predecrement
Address Register Indirect with index and displacement
Program counter relative with displacement
Program counter relative with index and displacement

I've got Paul Overaa's Mastering Amiga Assembler and I also have an abacus assembler book and both explain how addressing works, but I must be thick or something cuz I just cannot get it in my head and understand it!

So what I want to know is:

How do they work?
In what situation would one be better than another?
maybe examples would be good that I can question
BippyM is offline  
Old 24 January 2005, 19:45   #2
Codetapper
2 contact me: email only!
 
Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
They're just names and you don't have to know what they mean. It is just the difference between things like this:

moveq #5,d0
move.l d0,(a0)
move.l d0,(a0)+
move.l d0,-(a0)
move.l (5,a1),(a0)
move.l (5,a1),(a0)+
move.l (5,a1),-(a0)

etc...

Last edited by Codetapper; 24 January 2005 at 20:53.
Codetapper is offline  
Old 24 January 2005, 19:59   #3
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
Right /scratches head!!!
BippyM is offline  
Old 25 January 2005, 08:14   #4
Joe Maroni
Moderator
 
Joe Maroni's Avatar
 
Join Date: Feb 2003
Location: Germany
Age: 44
Posts: 1,303
Send a message via MSN to Joe Maroni


if you get grips of this some day you will see it´s easier than you think...
Joe Maroni is offline  
Old 25 January 2005, 08:26   #5
jmmijo
Junior Member
 
jmmijo's Avatar
 
Join Date: Jan 2002
Location: PDX
Age: 62
Posts: 2,395
Quote:
Originally Posted by Codetapper
They're just names and you don't have to know what they mean. It is just the difference between things like this:

moveq #5,d0
move.l d0,(a0)
move.l d0,(a0)+
move.l d0,-(a0)
move.l (5,a1),(a0)
move.l (5,a1),(a0)+
move.l (5,a1),-(a0)

etc...
Man, I knew enough to be dangerous but that's about it, however let's see if the little gray cells know what some of this means here Codetapper

For instance:

move.l d0,(a0)

Means move.something from data zero to address zero ?!? Or was it the other way around, from address zero to data zero ?!?

Geeze, I guess I'm not remembering much myself
jmmijo is offline  
Old 25 January 2005, 10:36   #6
Joe Maroni
Moderator
 
Joe Maroni's Avatar
 
Join Date: Feb 2003
Location: Germany
Age: 44
Posts: 1,303
Send a message via MSN to Joe Maroni
ok, first:

moveq #5,D0 ;move the value 5 (decimal) to the dataregister 0
move.l d0,(a0) ;move the value that is located in d0 to the adress that stands in a0 (not in a0 direct, only to the adress that stands in a0...)

move.l d0,(a0)+ ;move the value that stands in d0 to the adress that stands in a0 and then increase the adress

move.l d0,-(a0) ;decrease first a0 and then move the value that stands in d0 to the adress that stands in a0

second will follow...
Joe Maroni is offline  
Old 25 January 2005, 15:40   #7
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
Quote:
Originally Posted by x_to
ok, first:

moveq #5,D0 ;move the value 5 (decimal) to the dataregister 0
move.l d0,(a0) ;move the value that is located in d0 to the adress that stands in a0 (not in a0 direct, only to the adress that stands in a0...)

move.l d0,(a0)+ ;move the value that stands in d0 to the adress that stands in a0 and then increase the adress

move.l d0,-(a0) ;decrease first a0 and then move the value that stands in d0 to the adress that stands in a0

second will follow...
Lets see if I follow that...

moveq #5,d0 ;puts 5 into d0 (like youi said )
move.l d0,(a0) ; so d0=5 and a0 points to $5443, so a0 now points to $5448 or is the actual contents of the address changed?
move.l d0,(a0)+ ; so a0 would become $5449 (add 5 to a0 then +1) or would the address directly be changed as above and then a0 points to the next address?
move.l d0,-(a0) ; as above but reversed??
BippyM is offline  
Old 25 January 2005, 15:53   #8
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
Very simple:
#: means a direct value
() means a location defined by the value in the parentheses
If there is an additional offset by a direct value it is outside or inside the parentheses depending on old or new style mnemonic syntax. Regardless the result is the sum of the values listed.

moveq #5,d0: move direct value 5 to register d0
Don't bother with the q thing, it is a cpu optimization that any decent assembler program will automatically add to it.

move.l d0,(a0): move the value of register d0 to the location stored in a0

move.l d0,(a0)+: same as above then increment a0 by the size of the operand in this case 4, as it is a longword

etc

You really should read some decent books on cpu architectures first.
A simple 8 bit cpu is a good start, to understand how and why 16 bit cpus are different.
Also 68k were designed to work nicely with compiled C code, many of the addressing modes are similar to typical C mechanisms so knowing C can help a lot.
IFW is offline  
Old 25 January 2005, 16:01   #9
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
I have a few books on Amiga asm and I think I have a book on the 68k cpu itself!!

Maybe I should start reading them and playing around with some source eh!
BippyM is offline  
Old 25 January 2005, 16:11   #10
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
First experiment with your own source code, reading others' on an amiga is not very useful as long as you have trouble with the basics, as there are plenty of things normally going on in a native miggy program, most related to programming the custom chips.
Write very simple programs of just a few lines if you have trouble understanding the addressing modes, then watch them execute step by step in a debugger, showing memory locations, values and registers.
Devpac 3 is excellent for this.
IFW is offline  
Old 25 January 2005, 16:13   #11
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
Cool and I just happen to have a perfect boxed copy of devpac3 with full manuals and the works
BippyM is offline  
Old 25 January 2005, 19:26   #12
Joe Maroni
Moderator
 
Joe Maroni's Avatar
 
Join Date: Feb 2003
Location: Germany
Age: 44
Posts: 1,303
Send a message via MSN to Joe Maroni
i use the asmpro...also very nice...
Joe Maroni is offline  
Old 25 January 2005, 20:44   #13
Codetapper
2 contact me: email only!
 
Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
Wink Moveq rules!

Quote:
Originally Posted by IFW
moveq #5,d0: move direct value 5 to register d0
Don't bother with the q thing, it is a cpu optimization that any decent assembler program will automatically add to it.
However, it's only 5 letters to type moveq and 6 to type move.l so it's worth manually typing them just to save your fingers!

This of course assumes that you know the value you are moving is within 8 bit range. As IFW says, if the value is a constant or might change at some point, move.l is better.

And I also think the Asm-One debugger is awesome - I've never been able to work out the Devpac/MonAm debugger (to be honest, I don't have a manual for it but the Asm-Pro debugger is so logical it doesn't need a manual).
Codetapper is offline  
Old 25 January 2005, 23:20   #14
Jim
 
Posts: n/a
Bippy,

This might help to get to grips with the basics of the 68000:

http://www.hildreds.freeserve.co.uk/WISM68/

But that's not the hard part (learning the instructions). The hard part is learning how to program all the Amiga's custom tricks and a million other things
 
Old 25 January 2005, 23:31   #15
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
cheers Jim I'll give it a butchers
BippyM is offline  
Old 25 January 2005, 23:35   #16
jmmijo
Junior Member
 
jmmijo's Avatar
 
Join Date: Jan 2002
Location: PDX
Age: 62
Posts: 2,395
Quote:
Originally Posted by bippym
cheers Jim I'll give it a butchers
Ah the trials and trivails of Supervisor mode
jmmijo is offline  
Old 26 January 2005, 07:57   #17
AmiGer
Registered User
 
AmiGer's Avatar
 
Join Date: Sep 2002
Location: Germany
Posts: 349
The 68000 Programmer's reference manual can be downloaded from

http://www.freescale.com/webapp/sps/...018rH3YTLC4622

or at

http://www.technoplaza.net/downloads....php?program=9

Just 646 pages, have fun...
AmiGer is offline  
Old 03 February 2005, 09:57   #18
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
hmm on aminet one of the asm tutorials by c00l-g, has 3 files about amiga assembler and amiga hardware in it, and in one of those files, the addressing modes are mentioned and examples given.

either asm_course.lha or asmcourse.lha
redblade 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
question on resourcing relative addressing ara Coders. Asm / Hardware 5 04 February 2012 23:42
Non-interlaced screen modes 8bitbubsy support.Other 0 06 December 2010 02:01
Memory addressing CmdrVimes Coders. General 7 25 October 2010 22:20
Memory Addressing Architecture Zetr0 support.Hardware 2 10 July 2007 16:55
Screen modes AndySch support.Apps 3 02 July 2006 07:01

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:39.

Top

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