flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Programming Language Design > On my new assembler

Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6183
Location: Kraków, Poland
I have finished the AVX macros, AVX2 and AVX-512 should be next. And then also lots of small instruction sets that need to be defined separately.

PS. I have converted this small snippet from fasm 1 that I once used to test the operation of AVX instructions:

Code:

include 'format/format.inc'
include 'avx.inc'

format PE64 NX GUI 5.0
entry start

section '.data' data readable writeable

  _title db 'AVX playground',0
  _error db 'AVX instructions are not supported.',0

  x dq 3.14159265389

  vectors_output:
    repeat 16i:0
        db 'ymm',`i,': %f,%f,%f,%f',13,10
    end repeat
    db 0

  buffer db 1000h dup ?

section '.text' code readable executable

  start:

        mov     eax,1
        cpuid
        and     ecx,18000000h
        cmp     ecx,18000000h
        jne     no_AVX
        xor     ecx,ecx
        xgetbv
        and     eax,110b
        cmp     eax,110b
        jne     no_AVX

        vbroadcastsd ymm0,[x]
        vsqrtpd ymm1,ymm0
        vsubpd ymm2,ymm0,ymm1
        vsubpd ymm3,ymm1,ymm2

        vaddpd xmm4,xmm2,xmm3
        vaddpd ymm5,ymm4,ymm0
        vperm2f128 ymm6,ymm4,ymm5,03h

        vsqrtpd ymm7,ymm6

        vshufpd ymm8,ymm6,ymm5,10010011b
        vroundpd ymm9,ymm8,0011b
        vroundpd ymm10,ymm8,0

        sub     rsp,418h

    repeat 16i:0
        vmovups [rsp+10h+i*32],ymm#i
    end repeat

        mov     r8,[rsp+10h]
        mov     r9,[rsp+18h]
        lea     rdx,[vectors_output]
        lea     rcx,[buffer]
        call    [sprintf]

        xor     ecx,ecx
        lea     rdx,[buffer]
        lea     r8,[_title]
        xor     r9d,r9d
        call    [MessageBoxA]

        xor     ecx,ecx
        call    [ExitProcess]

  no_AVX:

        sub     rsp,28h

        xor     ecx,ecx
        lea     rdx,[_error]
        lea     r8,[_title]
        mov     r9d,10h
        call    [MessageBoxA]

        mov     ecx,1
        call    [ExitProcess]

section '.idata' import data readable writeable

  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA user_name,RVA user_table
  dd 0,0,0,RVA msvcrt_name,RVA msvcrt_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dq RVA _ExitProcess
    dq 0
  user_table:
    MessageBoxA dq RVA _MessageBoxA
    dq 0
  msvcrt_table:
    sprintf dq RVA _sprintf
    dq 0

  kernel_name db 'KERNEL32.DLL',0
  user_name db 'USER32.DLL',0
  msvcrt_name db 'MSVCRT.DLL',0

  _ExitProcess dw 0
    db 'ExitProcess',0
  _MessageBoxA dw 0
    db 'MessageBoxA',0
  _sprintf dw 0
    db 'sprintf',0

This has been lying around on my drive for years, I think that I should have made it into one of the official examples at some point.
Post 02 Feb 2017, 19:35
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6183
Location: Kraków, Poland
Turns out writing AVX2 macros went quickly. And AVX-512 ones are already underway.
Post 03 Feb 2017, 18:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6183
Location: Kraków, Poland
The "hq7d2" release introduces a new variant of POSTPONE directive, invoked with "postpone ?" construction. The assembler refrains from processing such block until it has nothing else to do, so it is a good place for tasks like computing checksums or constructing and displaying summaries/listings, as it allows to avoid processing these things unnecessarily in the intermediate passes. I have modified the PE formatting macros so that they use this feature when computing PE checksum, and I made them compute checksum always, as fasm 1 did.

Note that it should not be recommended to use any values defined inside "postpone ?" block outside of it, as it may interfere with the resolving process and make things worse than when this feature was not used.

I have also prepared a copy of fasmg repository that can be browsed online, for anyone interested.
Post 06 Mar 2017, 14:29
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 323
My question how load 256 bits ?
MyVal dd 1.0,2.0,3.0,4.0,5.0,6.0,1.0,7.0
I write vmovups ymm1,[MyVal] but fasm get me error operand size do not match !
How say fasm i want load 256 bits in ymm1 from MyVal ?

Use qqword ?
vmovups ymm1,qqword [MyVal]
Post 07 Mar 2017, 06:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14471
Location: ?                               Posts: 6699
Roman: are you asking about fasmg or fasm?
Post 07 Mar 2017, 07:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6183
Location: Kraków, Poland

Roman wrote:
My question how load 256 bits ?
MyVal dd 1.0,2.0,3.0,4.0,5.0,6.0,1.0,7.0
I write vmovups ymm1,[MyVal] but fasm get me error operand size do not match !
How say fasm i want load 256 bits in ymm1 from MyVal ?

Use qqword ?
vmovups ymm1,qqword [MyVal]

Both fasm 1 and fasmg allow to define a label with associated size:

Code:
label MyVal:qqword
dd 1.0,2.0,3.0,4.0,5.0,6.0,1.0,7.0

You can use "yword" in place of "qqword" if you prefer. And with fasmg you can also specify a size as a plain number (counting bytes):

Code:
label MyVal:32

Post 07 Mar 2017, 07:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.