![]() |
![]() |
#1 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
68000 code optimisations
Thread title says it all really.
I'm interested in the quickest ways to do things on the 68000 processor. I imagine that an optimisation that is valid for 68000 might not necessarily be valid for > 68000 processors but my main interest is in vanilla 68000 coding. So, if you have any, please post them here. ![]() In the meantime, some from me. Right hand operand(s) accomplish (according to my own testing, correct me if I'm wrong! ![]() Code:
68000 code speed optimisations ------------------------------ clr.l d0 --> moveq.l #0,d0 lsl.w #1,d0 --> add.w d0,d0 lsl.w #2,d0 --> add.w d0,d0 add.w d0,d0 adda.w #10,a0 --> lea 10(a0),a0 moveq.l #16,d0 --> swap d1 ror.l d0,d1 moveq.l #15,d0 --> swap d1 ror.l d0,d1 rol.l #1,d1 |
![]() |
![]() |
#2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
I could add a longer list here, but you could also refer to
http://sun.hasenbraten.de/vasm/release/vasm.html which shows most of vasm's optimizations in chapter 13.5. |
![]() |
![]() |
#3 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Thanks phx - been reading those optimisations at that link you posted - nice!
![]() So far I haven't used your VASM assembler (sorry about that ![]() ![]() Last edited by pmc; 03 February 2011 at 13:16. Reason: no need for the question I thought was needed :D |
![]() |
![]() |
#4 |
Banned
Join Date: Jan 2007
Location: France
Posts: 655
|
addq.l #,ax --> addq.w #,ax
b/jsr subroutine --> bra/jmp subroutine rts |
![]() |
![]() |
#5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
|
![]() |
![]() |
#6 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
According to the manual:
addq.l #x,An = 8 clock cycles addq.w #x,An = 4 clock cycles |
![]() |
![]() |
#7 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,570
|
It is wrong. (compare it with SUBAQ in same page). 68000/010 can't execute one instruction with two ALU operations in 4 cycles (ALU is only 16-bit and all address register operations are always full 32-bit)
|
![]() |
![]() |
#8 | |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
![]() Have you told Motorola their manual's wrong...? ![]() |
|
![]() |
![]() |
#9 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,016
|
How about:
add.w d4,a0 move.l (a0),a1 as move.l 0(a0,d4.w),a1 Also using the movem.l instruction to move lots of longwords in one instruction as opposed to a more processor intensive loop Last edited by Galahad/FLT; 03 February 2011 at 22:56. Reason: Back-to-back posts merged. Use the edit function. |
![]() |
![]() |
#10 |
Banned
Join Date: Jan 2007
Location: France
Posts: 655
|
... move.l 0(a0,d4.l),a1
![]() |
![]() |
![]() |
#11 | |
Registered User
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
|
Quote:
Also, I think that in the 68010 manual both are reported 8 cyles |
|
![]() |
![]() |
#12 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,570
|
"Undocumented un-optimization": bset x,dn (and friends) take 2 cycles more if x >= 16.
|
![]() |
![]() |
#13 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
I heard that the movem instruction can be used to clear screens quickly. Is this true and how would it be done?
Regards, Lonewolf10 |
![]() |
![]() |
#14 | |
Registered User
Join Date: Jun 2008
Location: Boston USA
Posts: 466
|
Quote:
Zero all registers and Code:
rept lots of times movem.l d0-a6,-(sp) endr ![]() Last edited by frank_b; 29 July 2012 at 13:06. Reason: Added code tags |
|
![]() |
![]() |
#15 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,016
|
|
![]() |
![]() |
#16 |
Registered User
Join Date: Jun 2008
Location: Boston USA
Posts: 466
|
Code:
and.w #power of 2-1,d0 Code:
move.w x,d0 and.w #$f,d0 ; blitter shift value Code:
move.b d0,-(sp) move.w (sp)+,d0 ; magic fast shift :) If you call functions and pass params via the stack might be useful. Code:
move.w #something,-(sp) trap #x move.w #some other param,-(sp) trap #x addq.l #4,sp ; clean up both params at once Code:
move.w #val,$ffff8240.w Code:
move.l somevar,d0 beq.s itiszero itiszero blah blah blah Last edited by frank_b; 29 July 2012 at 13:07. Reason: Added code tags |
![]() |
![]() |
#17 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
|
![]() |
![]() |
#18 |
Banned
Join Date: Jan 2007
Location: France
Posts: 655
|
How many penality cycles on 68000/010 for :
ax = $00005000 move.l #$12345678,3(ax) And for 020+ with datacache ?? |
![]() |
![]() |
#19 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
![]() |
![]() |
#20 | |||
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
Quote:
Quote:
Comparing for a specific value would still be needed of course. ![]() |
|||
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
68000 boot code | billt | Coders. General | 15 | 05 May 2012 20:13 |
Wasted Dreams on 68000 | sanjyuubi | support.Games | 5 | 27 May 2011 17:11 |
680x0 to 68000 | Counia | Hardware mods | 1 | 01 March 2011 10:18 |
quitting on 68000? | Hungry Horace | project.WHDLoad | 60 | 19 December 2006 20:17 |
3D code and/or internet code for Blitz Basic 2.1 | EdzUp | Retrogaming General Discussion | 0 | 10 February 2002 11:40 |
|
|