News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

@Arch

Started by Biterider, May 10, 2020, 07:18:19 PM

Previous topic - Next topic

Biterider

Hi
I'm not sure if I understand the behaviour of "option Arch:xxx" in 64 bit correctly  :rolleyes: (http://masm32.com/board/index.php?topic=8451.msg92482#msg92482).
I came across this while passing a REAL4 as an argument of a 64 bit proc using an older mobile CPU that doesn't support vector instructions and crashed the app when running (Exception instruction not supported).
Because of this, I commented out the "option Arch:AVX" for my own code (that uses vector instructions) and all was fine again, even if @Arch reported 1.
This is, afaik because in 64 bit, AVX is the default. What is strange is the following inconsistency. I use this simple code:

MyProc proc r4:REAL4
  %echo $ToStr(%@Arch)          ;This echoes the content of @Arch
  fld r4
  ret
MyProc endp


Scenario 1: option commented out
;option arch:AVX
echo @Arch => 1

  invoke MyProc, r4MyVal
000000013FF8001C  movd        xmm0,dword ptr [r4MyVal] 
000000013FF80021  call        MyProc (013FF7F174h) 


Scenario 2: option Arch:SSE
option arch:SSE
echo @Arch => 0

  invoke MyProc, r4MyVal
000000013FF8001C  movd        xmm0,dword ptr [r4MyVal] 
000000013FF80021  call        MyProc (013FF7F174h) 


Scenario 3: option Arch:SSE
option arch:AVX
echo @Arch => 1
  invoke MyProc, r4MyVal
000000013F10F6E7  vmovd       xmm0,dword ptr [r4MyVal] 
000000013F10F6EC  call        MyProc (013F10F174h) 


As you can see, the default @Arch = 1 isn't working when invoke is called.

Biterider

KradMoonRa

Hi Biterider,

Some inconsistency exist with UASM 2.49.1 or lower. John fixed this in the uasm 2.50 branch. With @Arch or invoke moves.



    IFNDEF ARCH_SSE
    ARCH_SSE EQU 0
    ENDIF
   
    IFNDEF ARCH_AVX
    ARCH_AVX EQU 1
    ENDIF
   
    IF @Arch EQ ARCH_AVX
        MOV EAX, val
        VMOVD reg, EAX
    ELSE
        MOV EAX, val
        MOVD reg, EAX
    ENDIF

    .IF @Arch EQ ARCH_AVX
        MOV EAX, val
        VMOVD reg, EAX
    .ELSE
        MOV EAX, val
        MOVD reg, EAX
    .ENDIF

    echo @Arch EQ ARCH_SSE   ;;0 true if @Arch == 0
    echo @Arch EQ ARCH_AVX   ;;1 true if @Arch == 1

    echo @Arch GE ARCH_SSE   ;;0 true if @Arch >= 0 (inclusive 1)
    echo @Arch GE ARCH_AVX   ;;1 true if @Arch >= 1

The uasmlib

Biterider

Hi KradMoonRa
OK, good to know. Thanks.

Biterider