24 January 2005, 18:20 | #1 |
Global Moderator
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 |
24 January 2005, 19:45 | #2 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,187
|
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. |
24 January 2005, 19:59 | #3 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Right /scratches head!!!
|
25 January 2005, 08:14 | #4 |
Moderator
|
if you get grips of this some day you will see it´s easier than you think... |
25 January 2005, 08:26 | #5 | |
Junior Member
Join Date: Jan 2002
Location: PDX
Age: 62
Posts: 2,396
|
Quote:
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 |
|
25 January 2005, 10:36 | #6 |
Moderator
|
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... |
25 January 2005, 15:40 | #7 | |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Quote:
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?? |
|
25 January 2005, 15:53 | #8 |
Moderator
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. |
25 January 2005, 16:01 | #9 |
Global Moderator
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! |
25 January 2005, 16:11 | #10 |
Moderator
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. |
25 January 2005, 16:13 | #11 |
Global Moderator
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
|
25 January 2005, 19:26 | #12 |
Moderator
|
i use the asmpro...also very nice...
|
25 January 2005, 20:44 | #13 | |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,187
|
Moveq rules!
Quote:
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). |
|
25 January 2005, 23:20 | #14 |
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 |
25 January 2005, 23:31 | #15 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
cheers Jim I'll give it a butchers
|
25 January 2005, 23:35 | #16 | |
Junior Member
Join Date: Jan 2002
Location: PDX
Age: 62
Posts: 2,396
|
Quote:
|
|
26 January 2005, 07:57 | #17 |
Registered User
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... |
03 February 2005, 09:57 | #18 |
Zone Friend
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 |
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 |
|
|