The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
January 22, 2020, 04:54:39 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Campus
| | |-+  macro for loop unrolling?
« previous next »
Pages: [1] Print
Author Topic: macro for loop unrolling?  (Read 2930 times)
liamo1
Guest


Email
macro for loop unrolling?
« on: August 30, 2010, 01:23:23 AM »

I was just wondering if anyone had a macro for loop unrolling. I was thinking that a new command such as foru could be developed in a macro. I'm a newbie to assembly and macros and just thought I'd ask BigGrin
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: macro for loop unrolling?
« Reply #1 on: August 30, 2010, 01:47:41 AM »

There is no specific macro, but REPEAT is often being used:
Code:
align 16
repct = 16 ; unrolling helps, but make sure that the count is divisible by the rep count!!
@@:
REPEAT repct
movaps xmm0, [eax+edx]
mulps xmm0, [edx]
lea edx, [edx+16]
addps xmm7, xmm0
ENDM
cmp edx, ecx
jb @B
Logged

MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: macro for loop unrolling?
« Reply #2 on: August 30, 2010, 04:19:32 AM »

Itís not packaged as a macro (and ATM I don't see any good way it could be), but in masm32\examples\exampl10\timer_demos\unroll there is something similar.
Logged

eschew obfuscation
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: macro for loop unrolling?
« Reply #3 on: August 30, 2010, 04:30:05 AM »

The built in REPEAT macro does the job when the contents need to be duplicated (simple unroll) but some algos have different offsets for data in each iteration. I have seen this done with a macro but it can get a bit complicated. You always have the option to just manually code an unroll if its too complicated to automate with REPEAT.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
bomz
Member
*****
Posts: 610



Re: macro for loop unrolling?
« Reply #4 on: August 30, 2010, 06:20:13 AM »

Quote
@@:
cmp eax, edx
jz @B:
† † please explain me this part of code

@ replaced by assembler with index number????

Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: macro for loop unrolling?
« Reply #5 on: August 30, 2010, 09:13:55 AM »

Quote
@@:
cmp eax, edx
jz @B:
† † please explain me this part of code

@ replaced by assembler with index number????


Go to Greg's post, download the Masm Programmer's Guide, and search inside for "Anonymous".
Logged

bomz
Member
*****
Posts: 610



Re: macro for loop unrolling?
« Reply #6 on: August 30, 2010, 09:26:01 AM »

удобненько comfortably
Quote
Anonymous Labels
When you code jumps in assembly language, you must invent many label names. One alternative to continually thinking up new label names is to use anonymous labels, which you can use anywhere in your program. But because anonymous labels do not provide meaningful names, they are best used for jumping over only a few lines of code. You should mark major divisions of a program with actual named labels.
Use two at signs (@@) followed by a colon (:) as an anonymous label. To jump to the nearest preceding anonymous label, use @B (back) in the jump instructionís operand field; to jump to the nearest following anonymous label, use @F (forward) in the operand field.
The jump in the following example targets an anonymous label:
† † † † jge† † †@F

† † † † .

@@:

The items @B and @F always refer to the nearest occurrences of @@:, so there is never any conflict between different anonymous labels.
Logged
liamo1
Guest


Email
Re: macro for loop unrolling?
« Reply #7 on: August 30, 2010, 07:37:21 PM »

Thank you all for the answers. I am trying to find out the optimal unroll depth for a dot product routine on my machine. I just tought I could be lazy and use a macro! BigGrin
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!