14 September 2010, 16:11 | #1 |
Badge 177
Join Date: Aug 2010
Location: Mirfield / UK
Posts: 77
|
Memory addressing
Hi chaps,
Can someone explain the difference between: Code:
LEA mylabel,a1 Code:
MOVE.l mylabel(PC),a1 |
14 September 2010, 16:51 | #2 |
Registered User
Join Date: Jun 2008
Location: somewhere else
Posts: 521
|
If mylabel would look like this:
mylabel: dc.l $12345678 Then in the 1st case a1 will contain the memory address of mylabel and in the 2nd case it's content as 32 bit word ($12345678), 2nd case is usually used for pointers. |
14 September 2010, 16:58 | #3 |
Badge 177
Join Date: Aug 2010
Location: Mirfield / UK
Posts: 77
|
|
14 September 2010, 18:32 | #4 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,810
|
They probably mean that the second form is used for retrieving a stored pointer, where the label points to the pointer storage space.
Basically, lea mylabel,a1 doesn't read from memory, and it just sets a1 to mylabel, while move.l mylabel(PC),a1 reads a 32 bit number from mylabel(pc) and stores it in a1. |
15 September 2010, 12:46 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,525
|
For example:
Code:
move.l #myLabel,a1 lea myLabel,a1 So why does LEA exist at all? Because you can load any effective address, which the immediate form of MOVE can't do: Code:
lea myLabel(pc),a1 lea 128(a0),a1 Code:
move.l myLabel(pc),a1 move.l myLabel,a1 |
24 October 2010, 00:51 | #6 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Ok, maybe I'm being stupid or too tired too think straight (I have been coding for about 7 hours straight), but there must be a better way to code this:
Code:
lea.l square(pc),a0 lea.l screen+3160(pc),a1 bsr drawbob lea.l square(pc),a0 lea.l screen+2840(pc),a1 bsr drawbob lea.l square(pc),a0 lea.l screen+2520(pc),a1 bsr drawbob ... Can anyone point me in the right direction, please? Regards, Lonewolf10 |
25 October 2010, 09:45 | #7 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Just create a table with the coordinates of the bob and read these coords in a loop. Eg. have a table like this:
COORDSTAB dc.w 3160, 2840, 2520 dc.w -1 ; end marker and the create a loop where you read the coords from the table and call your "drawbob" routine. |
25 October 2010, 22:20 | #8 | |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Quote:
Atleast I have my own working code, even if it is a little ugly! Code:
moveq #25,d7 ;number of coords-1 title_sq: move.w (a2)+,d0 ;next coord -> d0 move.l a3,d1 ;screen address -> d1 add.w d0,d1 ;add coord to screen address move.l d1,a1 ;move new address -> a1 * move.l (a3,d0.w),a1 ;was .l (crashes), .w doesn't work bsr drawbob ;ummm.... dbra d7,title_sq Regards, Lonewolf10 |
|
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 |
Blizzard Turbo Memory - SMD memory chips doesn't work | sanjyuubi | Hardware mods | 5 | 26 May 2010 15:40 |
[68000 ASM] Move memory to memory | AmigaBoy | Coders. General | 7 | 08 December 2009 08:16 |
Memory Addressing Architecture | Zetr0 | support.Hardware | 2 | 10 July 2007 16:55 |
Addressing modes | BippyM | Coders. General | 17 | 03 February 2005 09:57 |
|
|