05 May 2021, 13:30 | #1 |
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 50
Posts: 672
|
Differences betweed LEA label,Ax and MOVE.L #label.Ax
Can the 68k gurus cast some light on what are the differences between these two instructions?
cycles saved? some additional action not permitted? compatibility? Code:
LEA LABEL,A0 MOVE.L #LABEL,A0 |
05 May 2021, 13:43 | #2 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,213
|
LEA calculates an effective address... for example.
lea 2(a1,d4.w),a0 has a much different result than move.l 2(a1,d4.w),a0 but in terms of operation, the 2 examples you provided do practically the same thing |
05 May 2021, 13:57 | #3 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,018
|
In addition to what Dan said, if LABEL isn't more than $7fff bytes from the code that points to it, you can do:
Lea Label(pc),a0 Makes code smaller, and quicker still and relocatable. |
05 May 2021, 14:23 | #4 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,324
|
Quote:
As far as the outcome goes, there is no difference, result is the same. Actually, it is "MOVEA.L #label,a0" in your example, though the assembler silently fixed this for you. The difference between "MOVEA" and "MOVE" is that the former does not set the condition codes, the latter does. There is no "MOVE" to address register, but the assembler already spotted this, so no worries. |
|
05 May 2021, 15:25 | #5 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,213
|
and just to add more (complexity)...
movea.w #value,a0 will sign extend to a long.. so after: movea.w #$8000,a0 = a0.l will contain$ffff8000 |
05 May 2021, 15:41 | #6 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,358
|
As for timing, i can't tell for sure but normally there should be no difference.
Code has same size, nothing special. Normally the assembler is able to convert LEA label,a0to LEA label(pc),a0if optimisation is allowed. It is possible some assemblers can convert MOVEA to LEA but i'd recommend using LEA wherever it is an address. |
05 May 2021, 15:52 | #7 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,382
|
when disassembling some code, disassemblers convert LEA ADDRESS to the relevant label, but leave MOVE.L #value as is (because it could be a non-address value)
=> coders from the past please use LEA so we can reverse-engineer more easily |
05 May 2021, 16:51 | #8 | |
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 855
|
Quote:
My memory is fuzzy here, but I'm pretty sure that aeons ago while coding, I found that, at least on 68030 (and maybe also on 68020), movea.w #value,a0 takes as long as movea.l #value,a0. The same goes for lea.w and lea.l. I guess the reason is the sign extension. This is not mentioned in the manuals (but the MC68030UM manual does mention the 2 extra cycles regarding adda.w and suba.w, though). To me it's become a given, so I always keep it in mind. |
|
05 May 2021, 17:01 | #9 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
For the 68000 I do know that it's indeed the same speed for both move.w/add.w/lea.w/etc to an address register and move.l/add.l/lea.l/etc.
On the topic of LEA, while move.l #<label>,a0 and lea.l <label>,a0 do the same thing, I'd personally prefer the use of LEA. Reason being that move.l can be used for any value, but LEA always refers to an address. In my opinion, this makes it clearer what you're doing in the source code and can help prevent some errors by 'forcing' you to keep track of why you chose to use a certain instruction. It also helps (well, it helps me at any rate) to read code easier when I come back after a longer time. |
05 May 2021, 17:23 | #10 |
Registered User
Join Date: Jun 2015
Location: Germany
Posts: 1,927
|
Are you sure your assembler didn't convert them to PC-relative variants which it then shrunk to the smallest constant offset operand size it could? Then both .w and .l variants would have resulted in the same instruction.
|
05 May 2021, 17:33 | #11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
LEA.w does not exist. There is just LEA, which is a 32-bit operation.
|
05 May 2021, 17:35 | #12 | |
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 855
|
Quote:
Now, I should be doing other things, but curiosity might well push me to make some new tests... |
|
05 May 2021, 17:36 | #13 |
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 855
|
|
05 May 2021, 19:37 | #14 |
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 50
Posts: 672
|
Very interesting, thanks to all!
|
05 May 2021, 19:53 | #15 |
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 855
|
Well, it turns out that my past tests were broken and/or that my memory totally failed me Apologies to all.
I have made new tests on a standard A1200 and on the same A1200 with an Blizzard 1230-IV turned on - i.e., on a 14 MHz 68020 and on a 50 MHz 68030. The test were based on this simple loop (which executes 65536 times)... Code:
moveq.l #-1,d0 .l <movea/lea instruction> dbf d0,.l These are the results (times expressed in CIA ticks): Code:
instruction 68020 68030 ----------------------------------+-------+------- 41f8 55 lea.l $55.w,a0 | 8ccf | 2451 41f9 55 lea.l $552019,a0 | 999c | 2b96 307c 55 movea.w #$55,a0 | 8ccf | 2451 207c 55 2019 movea.l #$552019,a0 | 999c | 2b96 3040 movea.w d0,a0 | 6668 | 1d0d 2040 movea.l d0,a0 | 6668 | 1d0d |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Disk Label Dimensions | Methanoid | Retrogaming General Discussion | 6 | 20 July 2018 00:59 |
WB disk or label scans | Arnie | request.Other | 6 | 03 August 2016 11:34 |
drive label to device name | jotd | Coders. System | 4 | 28 December 2015 15:16 |
Dopus 4 disk label | videofx | request.Other | 2 | 08 June 2014 02:00 |
Label Program for Amiga | moxavius | support.Apps | 2 | 18 February 2012 13:59 |
|
|