05 May 2022, 10:45 | #1 |
Registered User
Join Date: Sep 2019
Location: Finland
Posts: 362
|
Loops with two instructions
I did some optimizing recently and shrunk a 7 instruction loop into this:
Code:
.loop cmp.l (a2)+,d0 dbhi d5,.loop Any other interesting examples of two instruction loops? |
14 May 2022, 12:39 | #2 |
Registered User
Join Date: Sep 2019
Location: Finland
Posts: 362
|
Having fun by myself here, bumped into this when looking at some source:
Code:
_FindMSBSet: move.b d1,d0 beq.s 2$ moveq #7,d0 1$: asl.b #1,d1 dbcs d0,1$ 2$: rts |
14 May 2022, 13:02 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
asl.b #1,d1could be optimized to add.b d1,d1(although the assembler would probably do that). IIRC, these kind of two-byte DBcc loops have an advantage on the 68010, because they are executed from a small cache. To give an example as well, I'm frequently using it to determine a string length: Code:
moveq #-1,d1 .1: tst.b (a0)+ dbeq d1,.1 not.w d1 |
14 May 2022, 14:06 | #4 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
The msbitset example above doesn't work if d1 is 0 (returns 0 if no bit is set or bit0 is set). Alternative (returns -1.w if no bit is set):
Code:
moveq #7,d0 Loop bclr d0,d1 dbne d0,Loop Last edited by a/b; 14 May 2022 at 14:13. Reason: btst lives matter |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copper Loops & Horizontal Waits | DanielAllsopp | Coders. Asm / Hardware | 7 | 03 November 2021 00:47 |
8svx samples/loops of analogue instruments | jotd | request.Music | 14 | 12 October 2021 08:12 |
New Zealand Story - small sample loops causing squeals | gary | support.Games | 1 | 23 July 2021 15:29 |
A600+Furia : WB ok, reset loops when opening anything else. Ok with NoFastMem | CDTV1991 | support.Hardware | 19 | 01 August 2020 17:24 |
Changing Floppy via Floppy Led Loops Sound | smoorke | support.WinUAE | 0 | 01 November 2009 17:53 |
|
|