![]() |
![]() |
#1 |
Registered User
Join Date: Dec 2019
Location: Preston
Posts: 100
|
![]()
So I'm just starting out, and fascinated by the 68000 optimisations thread
which got me wondering, I've seen numerous ways of clearing registers, and was wondering which of the following is the recommended way to clear a data register. Code:
sub.l dn, dn moveq.l #0, dn eor dn, dn clr.l dn Code:
movea.l #0, an suba.l an, an moveq.l #0, dn move.l dn, an eor dn, dn move.l dn, an clr.l dn move.l dn, an I'm very green when it comes to 68K assembler, so this is probably way too deep a topic for me, but as I said the optimisation thread piqued my interest. ![]() thanks Mike |
![]() |
![]() |
#2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,564
|
Code:
moveq #0,Dn suba.l An,An |
![]() |
![]() |
#3 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
This should be
Code:
moveq #0,Dn move.l D0,An Code:
suba.l An,An Last edited by sparhawk; 06 February 2020 at 12:40. |
![]() |
![]() |
#4 |
Registered User
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 195
|
@sparhawk
that's two separate instructions/aims: 1) clear data register "moveq #0,Dn" 2)clear address register "suba.l An,An" |
![]() |
![]() |
#5 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Yes. That makes sense.
![]() |
![]() |
![]() |
#6 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,453
|
While the above is 100% correct (in that the examples for clearing registers are either the fastest/smallest or both), I'd argue that focusing on this kind of optimization might not be the best way to go about it.
In code that is either time or space critical, I would definitely recommend using the examples as given (moveq / suba.l). However, there are many places in which a simple clr.w/clr.l effectively is just as good. My suggestion then is to use "what you like"*, unless you are trying to get the fastest (or smallest) possible code. Which is something you probably should only really do if you need to ![]() *) Within reason, of course. As an example: move.l #0,a0 will work but it needlessly wasteful in terms of space and performance. A suba.l a0,a0 or clr.l a0 (or a moveq #0,d0 vs a clr.l d0), however are both usually "good enough". Note this isn't to say you should just waste cycles or space without limits or reason. It's more that you're probably better off choosing the correct algorithms and then optimizing as needed instead of trying to do everything optimally all the time - pick your battles and all that. |
![]() |
![]() |
#7 | |
Registered User
Join Date: Dec 2019
Location: Preston
Posts: 100
|
Quote:
If I’m understanding you the main differences are down to assembled executable size, and cycle execution time. Is the best place to find cycle times the Motorola documentation, or is there a more accessible document? The other consideration when starting out teaching myself is that I’m inspecting available sourcecode to learn. Most of this is demo/intro code which by definition is either trying to be size conscious or speed conscious, so being able to understand what some of these alternative optimisations do will help aid understanding. Thanks again |
|
![]() |
![]() |
#8 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,453
|
The Motorola documentation (which, helpfully, is still on NXP's site) is awesome. Contains all you need to know. However, if all you want is a table of instructions and cycle uses I'd suggest looking at http://oldwww.nvg.ntnu.no/amiga/MC68...000timing.HTML
Which is perhaps easier to click through than reading the manual. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
noob copper question | jotd | Coders. Asm / Hardware | 4 | 10 January 2020 15:37 |
Noob Memory Question | CHRIS-F | support.Hardware | 5 | 05 July 2016 18:45 |
Noob question, sorry. | fitzsteve | project.WHDLoad | 3 | 23 August 2009 16:56 |
Noob Question but anyway. | trackah123 | Coders. General | 17 | 30 October 2008 14:39 |
yet another noob question | AliasXZ | New to Emulation or Amiga scene | 11 | 23 January 2008 23:28 |
|
|