Author Topic: Asmc source and binaries  (Read 17219 times)

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Asmc source and binaries
« Reply #135 on: August 03, 2018, 10:59:02 PM »
64 bit MASM is a MACRO assembler, thus "invoke", ".if", just finished "USING"

USING is better than USES I guess but .IF and INVOKE is a problem.

Quote
If by "limitation" you mean its not a C compiler, you are right but then CL.EXE does C compiler just fine where MASM is an assembler and it does assembler just fine as well.

The evil C stuff:
.if, .else, .elseif, .endif, .while, .endw, .repeat, .until, .untilcxz, .break, .continue, invoke, .startup, .exit, .switch, .case, .default, .endsw, .for, .endf.

All this is included in the MASM64 SDK so I guess this makes it a not a C compiler but a MACRO C compiler then.

The problem at hand is that all of this is supported by (ML,) JWASM, UASM, and ASMC. In order to be able to use any of these with the masm64 include files I will suggest the following (peace-meal) addition to masm64rt.inc:
Code: [Select]
ifdef __JWASM__
    option nokeyword:<.if>
    option nokeyword:<.else>
    option nokeyword:<.elseif>
    option nokeyword:<.endif>
    option nokeyword:<.while>
    option nokeyword:<.endw>
    option nokeyword:<.repeat>
    option nokeyword:<.until>
    option nokeyword:<.untilcxz>
    option nokeyword:<.break>
    option nokeyword:<.continue>
    option nokeyword:<invoke>
    option nokeyword:<.startup>
    option nokeyword:<.exit>
endif

ifdef __ASMC__
    option nokeyword:<rip>      ; should be fixed by renaming Rip to _Rip
    option nokeyword:<.switch>
    option nokeyword:<.case>
    option nokeyword:<.default>
    option nokeyword:<.endsw>
    option nokeyword:<.for>
    option nokeyword:<.endf>
endif

ifdef __UASM__
    option nokeyword:<rip>
    option nokeyword:<.switch>
    option nokeyword:<.case>
    option nokeyword:<.default>
    option nokeyword:<.endsw>
    option nokeyword:<.for>
    option nokeyword:<.endf>
    option nokeyword:<memalign> ; this fails..
endif

And the following changes to macros64.inc line 1218:
Code: [Select]
    getattr MACRO arg
      EXITM % (opattr(arg)) and 0FFh
    ENDM

Or a more integrated solution:
Code: [Select]
ifndef __JWASM__
.if MACRO args:VARARG
SaveOutLabel
SaveCurrentLabel
J_POLY_COND LastDefLabel,FALSE,<args>
ENDM
endif

I'm adding a 64-bit version of Asmc and a test version is added here. This will default to COFF 64BIT FASTCALL and behave (eventually) more or less like ML64.

If you add this to the bin64 folder, apply the changes above, and in addition to this rename it to ml64.exe, all the samples in the examples64 folder should hopefully build without any problems.

 :biggrin: everything is so complicated, empty example with macros64.inc first on ml64

Code: [Select]
Assembling: mywindow1.asm
macros64.inc(845) : error A2008:syntax error : switch
macros64.inc(849) : error A2006:undefined symbol : getattr
macros64.inc(856) : error A2006:undefined symbol : getattr
macros64.inc(858) : error A2006:undefined symbol : getattr
macros64.inc(862) : error A2008:syntax error : :
macros64.inc(863) : error A2006:undefined symbol : varsize
macros64.inc(865) : error A2006:undefined symbol : varsize
macros64.inc(867) : error A2006:undefined symbol : varsize
Unknown arg
macros64.inc(873) : error A2170:directive must appear inside a macro
macros64.inc(875) : error A2008:syntax error : :
macros64.inc(876) : error A2006:undefined symbol : regsize
macros64.inc(878) : error A2006:undefined symbol : regsize
macros64.inc(880) : error A2006:undefined symbol : regsize
Unknown arg
macros64.inc(887) : error A2008:syntax error : :
macros64.inc(888) : fatal error A1008:unmatched macro nesting
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'mywindow1.obj'
Press any key to continue . . .

I think the original macros should not be tied to system functions or or headers  :icon_confused: Even ml64 can not be represented as an absolute solution, since it is not a standard. Bottlenecks in macros must be unified, for the benefit of all.

And now on uasm64

Code: [Select]
macros64.inc(845) : Error A2210: Syntax error: MACRO arg
 macros64.inc(845): Included by
  mywindow1.asm(3): Main line code
macros64.inc(845) : Error A2143: Symbol redefinition: memalign
 macros64.inc(845): Included by
  mywindow1.asm(3): Main line code
macros64.inc(845) : Error A2082: Must be in segment block
 macros64.inc(845): Included by
  mywindow1.asm(3): Main line code
macros64.inc(849) : Error A2102: Symbol not defined : getattr
 macros64.inc(849): Included by
  mywindow1.asm(3): Main line code
macros64.inc(856) : Error A2102: Symbol not defined : getattr
 macros64.inc(856): Included by
  mywindow1.asm(3): Main line code
macros64.inc(858) : Error A2102: Symbol not defined : getattr
 macros64.inc(858): Included by
  mywindow1.asm(3): Main line code
macros64.inc(862) : Error A2047: Syntax error: Unexpected colon
 macros64.inc(862): Included by
  mywindow1.asm(3): Main line code
macros64.inc(863) : Error A2102: Symbol not defined : varsize
 macros64.inc(863): Included by
  mywindow1.asm(3): Main line code
macros64.inc(865) : Error A2102: Symbol not defined : varsize
 macros64.inc(865): Included by
  mywindow1.asm(3): Main line code
macros64.inc(867) : Error A2102: Symbol not defined : varsize
 macros64.inc(867): Included by
  mywindow1.asm(3): Main line code
Unknown arg
macros64.inc(873) : Error A2179: Directive must appear inside a macro
 macros64.inc(873): Included by
  mywindow1.asm(3): Main line code
macros64.inc(875) : Error A2047: Syntax error: Unexpected colon
 macros64.inc(875): Included by
  mywindow1.asm(3): Main line code
macros64.inc(876) : Error A2102: Symbol not defined : regsize
 macros64.inc(876): Included by
  mywindow1.asm(3): Main line code
macros64.inc(878) : Error A2102: Symbol not defined : regsize
 macros64.inc(878): Included by
  mywindow1.asm(3): Main line code
macros64.inc(880) : Error A2102: Symbol not defined : regsize
 macros64.inc(880): Included by
  mywindow1.asm(3): Main line code
Unknown arg
macros64.inc(887) : Error A2047: Syntax error: Unexpected colon
 macros64.inc(887): Included by
  mywindow1.asm(3): Main line code
macros64.inc(888) : Error A2163: Unmatched macro nesting
 macros64.inc(888): Included by
  mywindow1.asm(3): Main line code
macros64.inc(892) : Error A2210: Syntax error: .
 macros64.inc(892): Included by
  mywindow1.asm(3): Main line code
macros64.inc(893) : Error A2082: Must be in segment block
 macros64.inc(893): Included by
  mywindow1.asm(3): Main line code
macros64.inc(897) : Error A2163: Unmatched macro nesting
 macros64.inc(897): Included by
  mywindow1.asm(3): Main line code
macros64.inc(901) : Error A2210: Syntax error: MACRO _args:vararg
 macros64.inc(901): Included by
  mywindow1.asm(3): Main line code
macros64.inc(901) : Error A2082: Must be in segment block
 macros64.inc(901): Included by
  mywindow1.asm(3): Main line code
macros64.inc(901) : Error A2082: Must be in segment block
 macros64.inc(901): Included by
  mywindow1.asm(3): Main line code
macros64.inc(919) : Error A2082: Must be in segment block
 macros64.inc(919): Included by
  mywindow1.asm(3): Main line code
macros64.inc(919) : Error A2082: Must be in segment block
 macros64.inc(919): Included by
  mywindow1.asm(3): Main line code
macros64.inc(924) : Error A2163: Unmatched macro nesting
 macros64.inc(924): Included by
  mywindow1.asm(3): Main line code
macros64.inc(928) : Error A2210: Syntax error: MACRO _default:vararg
 macros64.inc(928): Included by
  mywindow1.asm(3): Main line code
macros64.inc(928) : Error A2082: Must be in segment block
 macros64.inc(928): Included by
  mywindow1.asm(3): Main line code
macros64.inc(929) : Error A2082: Must be in segment block
 macros64.inc(929): Included by
  mywindow1.asm(3): Main line code
macros64.inc(929) : Error A2082: Must be in segment block
 macros64.inc(929): Included by
  mywindow1.asm(3): Main line code
macros64.inc(930) : Error A2210: Syntax error: _default
 macros64.inc(930): Included by
  mywindow1.asm(3): Main line code
macros64.inc(931) : Error A2163: Unmatched macro nesting
 macros64.inc(931): Included by
  mywindow1.asm(3): Main line code
macros64.inc(935) : Error A2247: Directive must be in control block
 macros64.inc(935): Included by
  mywindow1.asm(3): Main line code
macros64.inc(949) : Error A2080: Block nesting error: .endif
 macros64.inc(949): Included by
  mywindow1.asm(3): Main line code
macros64.inc(951) : Error A2163: Unmatched macro nesting
 macros64.inc(951): Included by
  mywindow1.asm(3): Main line code
macros64.inc(1758) : Error A2160: INVOKE requires prototype for procedure
 macros64.inc(1758): Included by
  mywindow1.asm(3): Main line code
аааа***************************
macros64.inc(1759) : Error A2169: General Failure
 REGISTER(109)[macros64.inc]: Macro called from
  procedure_call(19)[macros64.inc]: Macro called from
   macros64.inc(1759): Included by
    mywindow1.asm(3): Main line code
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'mywindow1.obj'
Press any key to continue . . .

All macros will be written separately from each other, for uasm64 as well  :eusa_boohoo:



hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5945
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Asmc source and binaries
« Reply #136 on: August 04, 2018, 12:38:57 AM »
Your error lists are meaningless without context. The MASM macro file is only for MASM, if you are using one of the Watcom forks, you will need to use the include files and macros that they supply.

> Even ml64 can not be represented as an absolute solution, since it is not a standard.

For MASM compatibility, MASM in 64 bit is the standard for 64 bit Windows as Microsoft use it themselves. If you are getting that many errors, there is something basic that you are doing wrong. Show us the code you are getting the errors with and someone may be able to help.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Asmc source and binaries
« Reply #137 on: August 04, 2018, 01:17:23 AM »
Your error lists are meaningless without context. The MASM macro file is only for MASM, if you are using one of the Watcom forks, you will need to use the include files and macros that they supply.

> Even ml64 can not be represented as an absolute solution, since it is not a standard.

For MASM compatibility, MASM in 64 bit is the standard for 64 bit Windows as Microsoft use it themselves. If you are getting that many errors, there is something basic that you are doing wrong. Show us the code you are getting the errors with and someone may be able to help.

Hi Hutch,

Quote
empty example with macros64.inc


jj2007

  • Member
  • *****
  • Posts: 8896
  • Assembler is fun ;-)
    • MasmBasic
Re: Asmc source and binaries
« Reply #138 on: August 04, 2018, 02:08:49 AM »
In order to be able to use any of these with the masm64 include files I will suggest the following (peace-meal) addition to masm64rt.inc:
Code: [Select]
ifdef __JWASM__
    option nokeyword:<.if>
    option nokeyword:<.else>
    option nokeyword:<.elseif>
    option nokeyword:<.endif>
    option nokeyword:<.while>
    option nokeyword:<.endw>
    option nokeyword:<.repeat>
    option nokeyword:<.until>
    option nokeyword:<.untilcxz>
    option nokeyword:<.break>
    option nokeyword:<.continue>
    option nokeyword:<invoke>
    option nokeyword:<.startup>
    option nokeyword:<.exit>
endif

This post has skipped my attention, thanks for pointing to it, LiaoMi. What nidud proposes is OK, although my preference would be to do it the other way round, i.e. if an assembler with HLL is detected, skip the definition of the .if etc macros:
it would still require some of Vasily's macros

It would require disabling the .if, invoke etc macros with e.g. IFIDNI @Assembler, <ML> then .if macro ...

Perhaps like this:
Code: [Select]
IFIDNI @Assembler, <ML>
  include VasilysMacros4ML64.inc   ; invoke, if else endif, repeat ... until, while ... wend, switch .. case .. endsw
ENDIF
include Macros4allAssemblers.inc

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5945
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Asmc source and binaries
« Reply #139 on: August 04, 2018, 12:31:18 PM »
LiaoMi,

No error in correct framework.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .const
      Green equ 7
      Red   equ 5

    .data
      hInstance7   qword 0
      CommandLine7 qword 0
      hInstance    qword 0
      CommandLine  qword 0
      hInstance6   qword 0
      CommandLine6 qword 0

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    mov    ecx,Green
    mov    hInstance, rax
    mov    CommandLine7, rax
    mov    hInstance7, Red
    mov    CommandLine6, rax
    mov    hInstance6, Red
    mov    CommandLine, rax
    mov    ecx, eax

    waitkey
    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Asmc source and binaries
« Reply #140 on: August 04, 2018, 04:45:13 PM »
LiaoMi,

No error in correct framework.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .const
      Green equ 7
      Red   equ 5

    .data
      hInstance7   qword 0
      CommandLine7 qword 0
      hInstance    qword 0
      CommandLine  qword 0
      hInstance6   qword 0
      CommandLine6 qword 0

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    mov    ecx,Green
    mov    hInstance, rax
    mov    CommandLine7, rax
    mov    hInstance7, Red
    mov    CommandLine6, rax
    mov    hInstance6, Red
    mov    CommandLine, rax
    mov    ecx, eax

    waitkey
    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end


Hi Hutch,

I have the same assembly errors, I think the problem is just in the SDK, with your SDK probably all going as it should. I use sdk from ToutEnMasm, I have to study each case separately, then I can say something more precisely. Thanks!

Vortex

  • Member
  • *****
  • Posts: 1873
Re: Asmc source and binaries
« Reply #141 on: August 04, 2018, 07:36:13 PM »
LiaoMi,

No error in correct framework.

Exactly. I can assemble and link LiaoMi's example.

nidud

  • Member
  • *****
  • Posts: 1614
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #142 on: August 09, 2018, 09:44:34 PM »
Fixed a bug in the .pragma(init(...)) directive. This always created an exit record.

Asmc64 is now build as a 32-bit binary. This shaves off around 100K and makes it a bit faster than the 64-bit version. The benchmark used is the \masm32\m64lib\*.asm directory (somewhat modified) and the math test without .cpu and .model directive using ML64 version 12.

real_math:
Code: [Select]
5804 ClockTicks: ml64 -c -nologo real_math.asm
3651 ClockTicks: asmc64 -q real_math.asm

m64lib:
Code: [Select]
7270 ClockTicks: ml64.exe -c -nologo @ml.rsp
2698 ClockTicks: asmc64.exe -q @ml.rsp

jj2007

  • Member
  • *****
  • Posts: 8896
  • Assembler is fun ;-)
    • MasmBasic
Re: Asmc source and binaries
« Reply #143 on: August 10, 2018, 12:08:24 AM »
Asmc64 is now build as a 32-bit binary. This shaves off around 100K and makes it a bit faster than the 64-bit version.

I love fast software, that's why I'm here :icon_mrgreen:

nidud

  • Member
  • *****
  • Posts: 1614
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #144 on: August 15, 2018, 05:25:10 AM »
Added a AVX implementation of the memcpy() using a switch with overlapping moves. The overhang for small counts are basically removed by using this method.

The AVX 32 byte version:
Code: [Select]
    .code

    mov rax,rcx

    .if r8 <= 32

        option switch:notest

        .switch r8

          .case 0
            ret

          .case 1
            mov cl,[rdx]
            mov [rax],cl
            ret

          .case 2,3,4
            mov cx,[rdx]
            mov dx,[rdx+r8-2]
            mov [rax+r8-2],dx
            mov [rax],cx
            ret

          .case 5,6,7,8
            mov ecx,[rdx]
            mov edx,[rdx+r8-4]
            mov [rax+r8-4],edx
            mov [rax],ecx
            ret

          .case 9,10,11,12,13,14,15,16
            mov rcx,[rdx]
            mov rdx,[rdx+r8-8]
            mov [rax],rcx
            mov [rax+r8-8],rdx
            ret

          .case 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32
            movdqu xmm0,[rdx]
            movdqu xmm1,[rdx+r8-16]
            movups [rax],xmm0
            movups [rax+r8-16],xmm1
            ret
        .endsw
    .endif

    vmovdqu ymm1,[rdx]
    vmovdqu ymm2,[rdx+r8-32]
    .if r8 > 64

        mov ecx,eax
        neg ecx
        and ecx,32-1
        add rdx,rcx
        mov r9,r8
        sub r9,rcx
        add rcx,rax
        and r9b,-32

        .if rcx > rdx

            .repeat
                sub r9,32
                vmovdqu ymm0,[rdx+r9]
                vmovdqa [rcx+r9],ymm0
            .untilz
            vmovdqu [rax],ymm1
            vmovdqu [rax+r8-32],ymm2
            ret
        .endif

        lea rcx,[rcx+r9]
        lea rdx,[rdx+r9]
        neg r9
        .repeat
            vmovdqu ymm0,[rdx+r9]
            vmovdqa [rcx+r9],ymm0
            add r9,32
        .untilz
    .endif
    vmovdqu [rax],ymm1
    vmovdqu [rax+r8-32],ymm2
    ret

    end

The AVX 64 byte version:
Code: [Select]
    .code

    mov rax,rcx

    .if r8 <= 64

        option switch:notest

        .switch r8

          .case 0
            ret

          .case 1
            mov cl,[rdx]
            mov [rax],cl
            ret

          .case 2,3,4
            mov cx,[rdx]
            mov dx,[rdx+r8-2]
            mov [rax+r8-2],dx
            mov [rax],cx
            ret

          .case 5,6,7,8
            mov ecx,[rdx]
            mov edx,[rdx+r8-4]
            mov [rax+r8-4],edx
            mov [rax],ecx
            ret

          .case 9,10,11,12,13,14,15,16
            mov rcx,[rdx]
            mov rdx,[rdx+r8-8]
            mov [rax],rcx
            mov [rax+r8-8],rdx
            ret

          .case 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32
            movdqu xmm0,[rdx]
            movdqu xmm1,[rdx+r8-16]
            movups [rax],xmm0
            movups [rax+r8-16],xmm1
            ret

          .case 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,\
                49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64
            vmovdqu ymm0,[rdx]
            vmovdqu ymm1,[rdx+r8-32]
            vmovups [rax],ymm0
            vmovups [rax+r8-32],ymm1
            ret
        .endsw
    .endif

    vmovdqu ymm2,[rdx]
    vmovdqu ymm3,[rdx+32]
    vmovdqu ymm4,[rdx+r8-32]
    vmovdqu ymm5,[rdx+r8-64]

    .if r8 > 128

        mov ecx,eax
        neg ecx
        and ecx,64-1
        add rdx,rcx
        mov r9,r8
        sub r9,rcx
        add rcx,rax
        and r9b,-64

        .if rcx > rdx

            .repeat
                sub r9,64
                vmovdqu ymm0,[rdx+r9]
                vmovdqu ymm1,[rdx+r9+32]
                vmovdqa [rcx+r9],ymm0
                vmovdqa [rcx+r9+32],ymm1
            .untilz
            vmovdqu [rax],ymm2
            vmovdqu [rax+32],ymm3
            vmovdqu [rax+r8-32],ymm4
            vmovdqu [rax+r8-64],ymm5
            ret
            db 13 dup(0x90)
        .endif

        lea rcx,[rcx+r9]
        lea rdx,[rdx+r9]
        neg r9
        .repeat
            vmovdqu ymm0,[rdx+r9]
            vmovdqu ymm1,[rdx+r9+32]
            vmovdqa [rcx+r9],ymm0
            vmovdqa [rcx+r9+32],ymm1
            add r9,64
        .untilz
    .endif
    vmovdqu [rax],ymm2
    vmovdqu [rax+32],ymm3
    vmovdqu [rax+r8-32],ymm4
    vmovdqu [rax+r8-64],ymm5
    ret

    end


total [1 .. 4], 1++
    25764 cycles 2.asm: switch 32 AVX
    25788 cycles 1.asm: switch 32 SSE
    27684 cycles 3.asm: switch 64 AVX
    47541 cycles 0.asm: msvcrt.memcpy()

total [15 .. 17], 1++
    30200 cycles 2.asm: switch 32 AVX
    30364 cycles 3.asm: switch 64 AVX
    33621 cycles 1.asm: switch 32 SSE
    64903 cycles 0.asm: msvcrt.memcpy()

total [63 .. 65], 1++
    32243 cycles 3.asm: switch 64 AVX
    32869 cycles 2.asm: switch 32 AVX
    49630 cycles 1.asm: switch 32 SSE
    90890 cycles 0.asm: msvcrt.memcpy()

total [127 .. 129], 1++
    38979 cycles 3.asm: switch 64 AVX
    41102 cycles 2.asm: switch 32 AVX
    71012 cycles 1.asm: switch 32 SSE
   131579 cycles 0.asm: msvcrt.memcpy()

total [511 .. 513], 1++
    84769 cycles 3.asm: switch 64 AVX
    86763 cycles 2.asm: switch 32 AVX
   126420 cycles 1.asm: switch 32 SSE
   226737 cycles 0.asm: msvcrt.memcpy()

total [1023 .. 1025], 1++
   129894 cycles 3.asm: switch 64 AVX
   156393 cycles 2.asm: switch 32 AVX
   240375 cycles 1.asm: switch 32 SSE
   420802 cycles 0.asm: msvcrt.memcpy()

nidud

  • Member
  • *****
  • Posts: 1614
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #145 on: August 30, 2018, 02:26:05 AM »
Added some updates to the System V implementation.

The full set of 14 registers is now added. The index of each register depends on usage rather than position so the first used xmm register will always be xmm0:

p14 proto syscall :byte,
                  :real8,
                  :real8,
                  :real8,
                  :sword, ; extend 2..4
                  :dword,
                  :real4,
                  :real4,
                  :real4,
                  :qword,
                  :ptr,
                  :real8,
                  :real8,
                  :byte

    invoke p14,dil,xmm0,xmm1,xmm2,si,edx,xmm3,xmm4,xmm5,rcx,r8,xmm6,xmm7,r9b

        call    p14

    invoke p14,dil,xmm0,xmm1,xmm2,sil,edx,xmm3,xmm4,xmm5,rcx,r8,xmm6,xmm7,r9b

        movsx   esi, sil ; sign extend 1..4
        call    p14


    invoke p14,0,1.0,2.0,3.0,4,5,6.0,7.0,8.0,9,10,11.0,12.0,13

        mov     r9b, 13
        mov     rax, 4028000000000000H
        movq    xmm7, rax
        mov     rax, 4026000000000000H
        movq    xmm6, rax
        mov     r8d, 10  ; 8..4
        mov     ecx, 9   ; 8..4
        mov     eax, 1090519040
        movd    xmm5, eax
        mov     eax, 1088421888
        movd    xmm4, eax
        mov     eax, 1086324736
        movd    xmm3, eax
        mov     edx, 5
        mov     esi, 4   ; 2..4
        mov     rax, 4008000000000000H
        movq    xmm2, rax
        mov     rax, 4000000000000000H
        movq    xmm1, rax
        mov     rax, 3FF0000000000000H
        movq    xmm0, rax
        xor     dil, dil
        call    p14



jj2007

  • Member
  • *****
  • Posts: 8896
  • Assembler is fun ;-)
    • MasmBasic
Re: Asmc source and binaries
« Reply #146 on: September 06, 2018, 01:01:39 PM »
If code that work with ML don't work with AsmC,
   then AsmC is not compatible with ML

That seems to be correct. New version uploaded.

I tested the latest AsmC version with my major sources, including the difficult 64-bit text macro stuff posted here, all OK.

Speed is also fine (Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz):

RichMasm source (20,700 lines):
Code: [Select]
1200 ms AsmC
1415 ms UAsm64
1700 ms UAsm32

MasmBasic source (35,700 lines, 33 modules):
Code: [Select]
2400 ms AsmC
3200 ms UAsm64
7800 ms MASM (6.15, 10.0)

 :t

nidud

  • Member
  • *****
  • Posts: 1614
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #147 on: September 07, 2018, 09:06:59 AM »
Added HIGH64 and LOW64 operators.

These will only work in 64-bit with assumed input of a 128-bit const value. Const values used in invoke are stored in [RSP] (aligned shadow space) using RAX and loaded into corresponding xmm registers directly. This may now be done manually.

    mov rax,LOW64  1.23456789012345678901234567890123
    mov rdx,HIGH64 1.23456789012345678901234567890123
    mov [rsp],rax
    mov [rsp+8],rdx
    movaps xmm0,[rsp]

Or as a regular __int128 value:

    INT128_MIN  equ -170141183460469231731687303715884105728
    INT128_MAX  equ  170141183460469231731687303715884105727
    UINT128_MAX equ  340282366920938463463374607431768211455

    mov rax,LOW64  1
    mov rdx,HIGH64 1

    mov rax,LOW64  -2
    mov rdx,HIGH64 -2

    mov rax,LOW64  INT128_MIN
    mov rdx,HIGH64 INT128_MIN
    mov rax,LOW64  INT128_MAX
    mov rdx,HIGH64 INT128_MAX
    mov rax,LOW64  UINT128_MAX
    mov rdx,HIGH64 UINT128_MAX