News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Simple loop macro

Started by ASMManiac, February 08, 2012, 10:56:14 PM

Previous topic - Next topic

ASMManiac

I am trying to write a loop macro to read in a set of data into xmm registers
(I am using 64 bit assembly, so I DO have xmm0..xmm15)

FOR arg, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15>
        movdqu @catstr("xmm", <arg>), [rcx + (arg)*16]
    ENDM

I get the error:
error A2206:missing operator in expression


Am I calling catstr wrong?  If not, what is the macro actually expanding to?
Is there a way I can see the asm text generated by MASM post-macros?

qWord

literals must enclosed by <...> instead of "...". Your task can be solved without @CatStr:
FOR arg, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15>
        movdqu xmm&arg, [rcx +(arg)*16]
ENDM


For debugging macros, you can use listings: ml.exe ...  /Fllist.txt /Sn
Place the .nolist-directive at the first line of your source code. Immediately before the point of interest add .listall
FPU in a trice: SmplMath
It's that simple!

ASMManiac

Thank you, that worked perfectly!
Is there a way to write the loop without explicitely listing all the cases,
something like
For i=0:15
   ....
endM

qWord

cntr = 0
WHILE cntr LT 16
@CatStr(<movdqu xmm>,%cntr,<, [rcx + >,%cntr*16,<]>)
cntr = cntr + 1
ENDM
FPU in a trice: SmplMath
It's that simple!

ASMManiac

Also, I got an error when trying to do:
ml64.exe myAsm.asm  /Fllist.txt /Sn -> list.txt

It creates list.txt with the contents "MASM : warning A4018:invalid command-line option : -"

I added the "." commands into the file like you told me

qWord

Quoteml64.exe /Fllist.txt /Sn myAsm.asm
syr, that was ambiguous
FPU in a trice: SmplMath
It's that simple!

dedndave

ml64.exe myAsm.asm  /Fllist.txt /Sn -> list.txt

ml64.exe myAsm.asm  /Fllist.txt /Sn > list.txt

ASMManiac

Do you know of a way to do a similar compile-time macro in c++?

baltoro

...Oops, sorry,...nevermind,...I don't know what I'm talking about,...comment deleted,... :eek
Baltoro

qWord

Quote from: ASMManiac on February 09, 2012, 08:52:16 PM
Do you know of a way to do a similar compile-time macro in c++?
AFAIK it is not possible with loops, beacuse the cpp preprocessor doesn't have macro-loops. However, simply creating a macro, which hold 16 corresponding lines (movdqa ..,xmmX...) is possible.
FPU in a trice: SmplMath
It's that simple!

ASMManiac

I am trying out the .IF statement and running into trouble using ml64.exe

    .IF R8==16
        mov rax,5
    .ELSE
        mov rax,2
    .ENDIF


A similar question was asked here: http://social.msdn.microsoft.com/Forums/zh/vclanguage/thread/3f8aa123-64ca-4623-9ebb-11aa811ee428

They concluded that the .IF was removed from ml64.  Is there another built in keyword that does similar branching?

The errors I get are:
Transpose16x16A.asm(100) : error A2008:syntax error : IF
Transpose16x16A.asm(102) : error A2008:syntax error : .
Transpose16x16A.asm(104) : error A2008:syntax error : .


qWord

Quote from: ASMManiac on February 10, 2012, 04:16:47 PMThey concluded that the .IF was removed from ml64.  Is there another built in keyword that does similar branching?
no. Using the forum search, you maybe finder some macros that do this.
You should switch to jWasm, which has all this capacities: ml64.exe is mutilated version of ml.exe.
FPU in a trice: SmplMath
It's that simple!

ASMManiac

Thanks, I will look into jWasm.
Isn't ml64 just the 64 bit version of ml, so ml wouldn't be able to compile 64 bit assembly?

jj2007

It is, it is, but M$ decided that compilers have no need for .if ... .endif and all that, so they dropped high level language elements. Use JWasm, it's a perfect clone, much faster, too.