News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Directive query

Started by Biterider, April 07, 2020, 04:39:42 PM

Previous topic - Next topic

Biterider

Hi
Is there a way to determine at compile-time if the .xmm directive was activated?
I recently came to the situation where I had to disable a code path that uses sse instructions and it would have been handy to know if these instructions were enabled or not.

What about the more advanced instruction sets like sse2, sse3, ... avx2? Are there directives or options for them?  :rolleyes:
I checked the manual and found no reference. Maybe I'm missing something ...

Biterider

KradMoonRa

#1
Hi Biterider,

Think uasm in x64 defaults always implies to xmm if not option arch:avx or option evex:1 implies option arch:avx.

For 32bits the options are more vast an intriguing to do.
The uasmlib

mabdelouahab

Maybe this solves the problem  :biggrin:
ifdef xmm0
echo 1st check
endif
.xmm
ifdef xmm0
echo  2ndt check
endif



2ndt check

Make finished.
Total compile time 469 ms

Biterider

Hi
Thank you for your suggestions.  :thumbsup:
For now I will go with "ifdef xmm0"

Biterider

Biterider

Hi mabdelouahab
Unfortunately it doesnt work for me. I got the following output:
1st check
2ndt check


Maybe I'm doing something wrong. Can you post your complete code and UASM settings? That will help.

Biterider

mabdelouahab

C:\Masm32\Bin\ML.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include" "for_test.asm"
Assembling: for_test.asm

***********
ASCII build
***********

2ndt check

Make finished.
Total compile time 500 ms

include masm32rt.inc

.code
Start:
ifdef xmm0
echo 1st check
endif
.xmm
ifdef xmm0
echo  2ndt check
endif
inkey
exit
end Start


it doesnt work with UASM  :sad:

C:\Masm32\Bin\uasm64.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include" "for_test.asm"

***********
ASCII build
***********

1st check
2ndt check
for_test.Asm: 14 lines, 2 passes, 127 ms, 0 warnings, 0 errors

Make finished.
Total compile time 265 ms

Biterider

OK, thanks.
Quoteit doesnt work with UASM  :sad:

That is my problem too.

habran

Hi Biterider,

I think the solution is a variable @Arch. Here is how to use it in compile time (it is from UASM Extended Guide):
2.15) NEW LANGUAGE TYPES
Procedures can now be decorated with attribute SYSTEMV to generate a 64bit SystemV ABI call.
For example:
OPTION ARCH:SSE
nixproc PROC SYSTEMV FRAME USES rbx xmm0 arg1:qword, arg2:DWORD, arg3:REAL4
mov rbx,arg1
mov ecx,arg2
IF @Arch EQ 0
movss xmm10,arg3
ELSE
vmovss xmm10,arg3
ENDIF
ret
nixproc ENDP
OPTION ARCH:AVX

Cod-Father

jj2007

Quote from: habran on April 08, 2020, 10:44:29 AM
I think the solution is a variable @Arch

That works:
  ifdef @Arch
tmp$ CATSTR <Arch=>, %@Arch
% echo tmp$
.err
  endif


Output: Arch=1

It could be a little bit more verbose, given that nobody reads manuals, and of course it's not MASM-compatible, but it works indeed.

Biterider

Hi habran
That is what I was looking for. Thanks!  :thumbsup:

Biterider

habran

No problemo Biterider :biggrin:
Sometimes, when you run out of ideas look up the option.c . You can get an idea how it is implemented.
in this case it is this function:
/* OPTION ARCH:SSE/AVX */
OPTFUNC( SetArch )
{
int i = *pi;
struct asym *archSym = SymFind("@Arch");

if (tokenarray[i].token == T_ID) {
if (0 == _stricmp(tokenarray[i].string_ptr, "SSE")) {
MODULEARCH = ARCH_SSE;
ModuleInfo.arch = ARCH_SSE;
archSym->value = ARCH_SSE;
}
else if (0 == _stricmp(tokenarray[i].string_ptr, "AVX")) {
MODULEARCH = ARCH_AVX;
ModuleInfo.arch = ARCH_AVX;
archSym->value = ARCH_AVX;
}
else {
return(EmitErr(SYNTAX_ERROR_EX, tokenarray[i].tokpos));
}
DebugMsg1(("SetArch(%s) ok\n", tokenarray[i].string_ptr));
i++;
}
else {
return(EmitErr(SYNTAX_ERROR_EX, tokenarray[i].tokpos));
}
*pi = i;
return( NOT_ERROR );
}

Of course it is easier if you know what are you looking for :wink2:

I would suggest to every serious programmer to get familiar with option.c source file
Cod-Father