English Amiga Board Loops with two instructions
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 05 May 2022, 10:45 #1 koobo Registered User   Join Date: Sep 2019 Location: Finland Posts: 119 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``` The array in A2 contains magnitude values as an exponential curve. D0 contains the measurement. The result in D5 is a decibel representation of the magnitude minus one. I thought this was pretty neat. Any other interesting examples of two instruction loops?
 14 May 2022, 12:39 #2 koobo Registered User   Join Date: Sep 2019 Location: Finland Posts: 119 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``` Input is a byte in d1, output in d0 is the bit index of the first bit that is set in input.
 14 May 2022, 13:02 #3 phx Natteravn   Join Date: Nov 2009 Location: Herford / Germany Posts: 2,178 `asl.b #1,d1` could 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 a/b Registered User   Join Date: Jun 2016 Location: europe Posts: 623 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``` edit: btst works too ;P. 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)

 Similar Threads Thread Thread Starter Forum Replies Last Post DanielAllsopp Coders. Asm / Hardware 7 03 November 2021 00:47 jotd request.Music 14 12 October 2021 08:12 gary support.Games 1 23 July 2021 15:29 CDTV1991 support.Hardware 19 01 August 2020 17:24 smoorke support.WinUAE 0 01 November 2009 17:53

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.AmigaOS     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.Amiga File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials

All times are GMT +2. The time now is 11:11.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top