Author Topic: High Level Language in MASM  (Read 61413 times)

nikkho

  • Regular Member
  • *
  • Posts: 12
Re: High Level Language in MASM
« Reply #240 on: June 08, 2017, 01:42:53 AM »
Latest benchmark result.

This is amazing. Specially considering that ASMC 32 bit, is faster than JWASM and UASM 64 bit.

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: High Level Language in MASM
« Reply #241 on: June 08, 2017, 04:30:22 AM »
Hi nidud,

what is required to work with your latest attachment profile.zip?

Gunther
Get your facts first, and then you can distort them.

nidud

  • Member
  • *****
  • Posts: 1410
    • https://github.com/nidud/asmc
Re: High Level Language in MASM
« Reply #242 on: June 08, 2017, 04:56:28 AM »
Hi Gunther,

The test assume the following:

\masm32\bin\ml.exe
\jwasm\jwasm.exe
\hjwasm\hjwasm32.exe
\hjwasm\hjwasm64.exe
\hasm\hasm32.exe
\hasm\hasm64.exe
\uasm\uasm64.exe
\asmc\bin\asmc.exe

\masm32\m32lib\*.asm


You may have to edit the .CMD files to correct the path or remove missing binaries.

m32lib.cmd:
Code: [Select]
@echo off
if not exist ti.exe asmc /pe ti.asm
for %%q in (\masm32\m32lib\*.asm) do echo %%q >> ml.rsp
ti \jwasm\jwasm -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \hjwasm\hjwasm32 -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \hjwasm\hjwasm64 -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \hasm\hasm32 -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \hasm\hasm64 -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \uasm\uasm64 -q @ml.rsp >> result.txt
echo ..
del *.obj
ti \asmc\bin\asmc -q @ml.rsp >> result.txt
echo ..
del *.obj
del *.rsp
type result.txt
pause

math.cmd:
Code: [Select]
@echo off
if not exist ti.exe asmc /pe ti.asm
@ti \masm32\bin\ml -c -nologo real_math.asm > result.txt
echo ..
@ti \jwasm\jwasm -q real_math.asm >> result.txt
echo ..
@ti \hjwasm\hjwasm32 -q real_math.asm >> result.txt
echo ..
@ti \hjwasm\hjwasm64 -q real_math.asm >> result.txt
echo ..
@ti \hasm\hasm32 -q real_math.asm >> result.txt
echo ..
@ti \hasm\hasm64 -q real_math.asm >> result.txt
echo ..
@ti \uasm\uasm64 -q real_math.asm >> result.txt
echo ..
@ti \asmc\bin\asmc -q real_math.asm >> result.txt
echo ..
type result.txt
pause

nidud

  • Member
  • *****
  • Posts: 1410
    • https://github.com/nidud/asmc
Re: High Level Language in MASM
« Reply #243 on: August 27, 2017, 05:09:21 AM »
Made some adjustment to the 64-bit table-switch. It failed if the argument was 32-bit and tables was created.

Well, this was related to testing this:
It was my pleasure :biggrin:
I was always disappointed with the garbage which that HLL creates in the code section, even MSV$ does the same, now HASM jumped  far, far ahead, as AUDI says:"vorsprung durch technik" :t
The advantage of that is not only clear debug code but we can put more data there to make it faster and it will not bloat the code section.

Tried that too in the beginning but failed to see any advantage thought.

Quote
I have increased span between lowest and highest case from 512 to 2048 and it can be all executed with a few instructions from the above post.
So, if you need a speed for big amount of cases it can span from 0 to 2048

This crashed with the latest build of Uasm (v2.39):
Code: [Select]

    .x64
    .model  flat, fastcall

    option  dllimport:<msvcrt>
    printf  proto :ptr byte, :vararg
    exit    proto :qword

    .data
    error  db "Uasm Error: %d",10,0

    .code

sw_uasm proc val

    .switch ecx

    enum = 0
    repeat 300
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    enum = 600
    repeat 60
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    enum = 1000
    repeat 1000
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    .default
        xor eax,eax

    .endswitch
    ret

sw_uasm endp

main proc

    mov esi,299
    .while esi
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov esi,659
    .while esi >= 600
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov esi,1999
    .while esi >= 1000
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov edi,1000
    .while edi
        mov esi,2000
        .while esi
            invoke sw_uasm,esi
            dec esi
        .endw
        dec edi
    .endw
    invoke exit,0

main endp

    end main

Quote
UASM has a smart logic to use different kind of solution for different types of cases to keep data as small as possible without affecting the speed, however, smart programmer will chose wisely what cases to put together to create optimal code.
In my opinion every programmer is smart, stupid can not be programmer, they can only think that they are ;)

Well, this works:
Code: [Select]

    .x64
    .model  flat, fastcall

    option  dllimport:<msvcrt>
    printf  proto :ptr byte, :vararg
    exit    proto :qword

    .data
    error  db "Uasm Error: %d",10,0

    .code

sw_uasm proc val

    .switch ecx

    enum = 0
    repeat 300
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    enum = 600
    repeat 60
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    enum = 6000
    repeat 2000
%   .case @CatStr(%enum)
    mov eax,enum
    enum = enum + 1
    endm

    .default
        xor eax,eax

    .endswitch
    ret

sw_uasm endp

main proc

    mov esi,299
    .while esi
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov esi,659
    .while esi >= 600
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov esi,7999
    .while esi >= 6000
        invoke sw_uasm,esi
        .if eax != esi
            invoke printf,addr error,esi
            .break
        .endif
        dec esi
    .endw
    mov edi,1000
    .while edi
        mov esi,8000
        .while esi
            invoke sw_uasm,esi
            dec esi
        .endw
        dec edi
    .endw
    invoke exit,0

main endp

    end main

The code size is 62976 byte versus 60416 byte for Asmc.
benchmark:
Code: [Select]
   93 ClockTicks: sw_asmc
  406 ClockTicks: sw_uasm