News:

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

Main Menu

New HJWasm release

Started by habran, May 17, 2016, 06:30:15 AM

Previous topic - Next topic

habran

Hello everyone,
there is a new HJWasm release on the Terraspace with some sophisticated improvements 8)
Built in two new options for the .SWITCH block:
option SWITCHSTYLE : ASMSTYLE   (default)
option SWITCHSTYLE:  CSTYLE       (optional)
hutch, I hope you will be happy with this one, now you have ASMSTYLE .SWITCH block, thank you for your suggestion :t
Multiple cases can be used with the comma ',' and can be continued in new line if they don't fit in one
If you don't need .DEFAULT it can be omitted in both  ASMSTYLE or CSTYLE
This version also reduces memory consumption in multiple cases, it will create only one jump table for all cases in both styles.
You can switch to another style and go back to first one as many time as you want using option SWITCHSTYLE
here are some examples:
Quotemov eax, 184h
   .switch eax
   .case 179h,180h,1c5h,17bh,17dh,
   182h,184h,185h
     mov edx,1d5h
   .case 1d3h
     mov edx, 1d3h
   .case 1f4h
     mov edx, 1f4h
   .case 200h
      mov  edx, 200h
   .case 201h
     mov  edx, 201h
   .case 202h
     mov  edx, 202h
   .case 203h
     mov  edx, 203h
   .default                 
     mov edx, 0
   .endswitch

   option SWITCHSTYLE: CSTYLE

   mov eax, 184h
   .switch eax
   .case 179h, 180h, 1c5h, 17bh, 17dh,
   182h, 184h, 185h
   mov edx, 1d5h
   .break
   .case 1d3h
   mov edx, 1d3h
   .break
   .case 1f4h
   mov edx, 1f4h
   .break
   .case 200h
   mov  edx, 200h
   .break
   .case 201h
   mov  edx, 201h
   .break
   .case 202h
   mov  edx, 202h
   .break
   .case 203h
   mov  edx, 203h
   .break
   .default
   mov edx, 0
   .break
   .endswitch

option SWITCHSTYLE : ASMSTYLE

.switch bl
   .case 202
     mov  edx, 202
   .case 203
     mov  edx, 203
    .case 2013
     mov  edx, 213
   .endswitch
Cod-Father

jj2007

Well done :t

With my 800 lines testbed, it's much faster than ML and considerably faster than Japheth's last JWasm version:
  OxPT_Assembler  mlv615 ; 44.0kB, 1070 ms
  OxPT_Assembler  mlv10 ; 44.0kB, 1070 ms
  OxPT_Assembler  JWasm ; 44.0kB, 650 ms
  OxPT_Assembler  HJWasm32 ; 44.0kB, 580 ms
  OxPT_Assembler  HJWasm64 ; 44.0kB, 580 ms
  OxPT_Assembler  asmc ; 44.0kB, 480 ms


Note that there is no measurable speed difference between the 32-bit and 64-bit versions. The latter is 63% fatter, though ;)

Same pattern with the RichMasm source (17k lines):
OxPT_Assembler mlv10 ; 1200 ms
OxPT_Assembler mlv615 ; 1200 ms
OxPT_Assembler JWasm ; 880 ms
OxPT_Assembler HJWasm32 ; 820 ms
OPT_Assembler HJWasm64 ; 820 ms
OxPT_Assembler AsmC ; 740 ms


Now the surprise when building the MasmBasic library (28k lines):
OPT_Assembler mlv615 ; 6.9 secs
OxPT_Assembler JWasm ; 5.5 secs
OxPT_Assembler HJWasm32 ; 2.8
OxPT_Assembler HJWasm64 ; 4.2 secs
OxPT_Assembler AsmC ; 2.1 secs


The 32-bit version is consistently 50% faster 8)

habran

Thanks jj2007 :biggrin:
HJWasm32 has to deal with less code so it can be the reason,
but I suspect that your machine is more experienced in running 32 bit and hence the speed ;)
I have here example how much has the .SWITCH block being improved:
Quote

This code:
  mov eax, 1c5h
  .switch eax
   .case 179h,17bh,17dh,182h,184h,187h,18bh,191h,198h,
         1a0h,1a2h,1a4h,1a7h,1ach,1afh,1b3h,1b5h,1b8h,
         1bch,1c5h,1c8h,1cbh,1cdh,1cfh,1d1h,1d3h,1d5h,
         1d7h,1d9h,1dbh,1f2h,1f4h,200h
     mov  edx, 200h
   .case 201h
   mov  edx, 201h
   .case 202h
   mov  edx, 202h
   .case 203h
   mov  edx, 203h
  .default
   mov edx, 0
  .endswitch

Now it makes this:
?_021   LABEL NEAR
        sub     rsp, 472                                ; 40001165 _ 48: 81. EC, 000001D8
        mov     eax, 453                                ; 4000116C _ B8, 000001C5
        jmp     ?_023                                   ; 40001171 _ EB, 32

; Note: No jump seems to point here
        mov     edx, 512                                ; 40001173 _ BA, 00000200
        jmp     ?_026                                   ; 40001178 _ E9, 000000FF

; Note: No jump seems to point here
        mov     edx, 513                                ; 4000117D _ BA, 00000201
        jmp     ?_026                                   ; 40001182 _ E9, 000000F5

; Note: No jump seems to point here
        mov     edx, 514                                ; 40001187 _ BA, 00000202
        jmp     ?_026                                   ; 4000118C _ E9, 000000EB

; Note: No jump seems to point here
        mov     edx, 515                                ; 40001191 _ BA, 00000203
        jmp     ?_026                                   ; 40001196 _ E9, 000000E1

?_022:  mov     edx, 0                                  ; 4000119B _ BA, 00000000
        jmp     ?_026                                   ; 400011A0 _ E9, 000000D7

?_023:  cmp     eax, 515                                ; 400011A5 _ 3D, 00000203
        ja      ?_022                                   ; 400011AA _ 77, EF
        sub     eax, 377                                ; 400011AC _ 2D, 00000179
        jc      ?_022                                   ; 400011B1 _ 72, E8
        lea     rdx, ptr [?_025]                        ; 400011B3 _ 48: 8D. 15, 00000037(rel)
        movzx   rax, byte ptr [rax+rdx]                 ; 400011BA _ 48: 0F B6. 04 10
        lea     rdx, ptr [?_024]                        ; 400011BF _ 48: 8D. 15, 00000003(rel)
        jmp     qword ptr [rdx+rax*8]                   ; 400011C6 _ FF. 24 C2

?_024   label qword                                     ; switch/case jump table
        dq Unnamed_80000000_0                           ; 400011C9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011D1 _ 000000014000117D (d)
        dq Unnamed_80000000_0                           ; 400011D9 _ 0000000140001187 (d)
        dq Unnamed_80000000_0                           ; 400011E1 _ 0000000140001191 (d)
        dq Unnamed_80000000_0                           ; 400011E9 _ 000000014000119B (d)
[?_025] label byte
    db 00 04 00 04 00 04 04 04 04 00 04 00 04 04 00 04 04 04 00 04 04 04
    db 04 04 00 04 04 04 04 04 04 00 04 04 04 04 04 04 04 00 04 00 04 00
    db 04 04 00 04 04 04 04 00 04 04 00 04 04 04 00 04 00 04 04 00 04 04
    db 04 00 04 04 04 04 04 04 04 04 00 04 04 00 04 04 00 04 00 04 00 04
    db 00 04 00 04 00 04 00 04 00 04 00 04 04 04 04 04 04 04 04 04 04 04
    db 04 04 04 04 04 04 04 04 04 04 04 00 04 00 04 04 04 04 04 04 04 04
    db 04 04 04 00 01 02 03 b8 44 00 00 00 eb 66 e8 10 fe ff ff e9 aa 00


Before:


?_021   LABEL NEAR
        sub     rsp, 472                                ; 40001165 _ 48: 81. EC, 000001D8
        mov     eax, 453                                ; 4000116C _ B8, 000001C5
        jmp     ?_023                                   ; 40001171 _ EB, 32

; Note: No jump seems to point here
        mov     edx, 512                                ; 40001173 _ BA, 00000200
        jmp     ?_026                                   ; 40001178 _ E9, 000001FF

; Note: No jump seems to point here
        mov     edx, 513                                ; 4000117D _ BA, 00000201
        jmp     ?_026                                   ; 40001182 _ E9, 000001F5

; Note: No jump seems to point here
        mov     edx, 514                                ; 40001187 _ BA, 00000202
        jmp     ?_026                                   ; 4000118C _ E9, 000001EB

; Note: No jump seems to point here
        mov     edx, 515                                ; 40001191 _ BA, 00000203
        jmp     ?_026                                   ; 40001196 _ E9, 000001E1

?_022:  mov     edx, 0                                  ; 4000119B _ BA, 00000000
        jmp     ?_026                                   ; 400011A0 _ E9, 000001D7

?_023:  cmp     eax, 515                                ; 400011A5 _ 3D, 00000203
        ja      ?_022                                   ; 400011AA _ 77, EF
        sub     eax, 377                                ; 400011AC _ 2D, 00000179
        jc      ?_022                                   ; 400011B1 _ 72, E8
        lea     rdx, ptr [?_025]                        ; 400011B3 _ 48: 8D. 15, 00000137(rel)
        movzx   rax, byte ptr [rax+rdx]                 ; 400011BA _ 48: 0F B6. 04 10
        lea     rdx, ptr [?_024]                        ; 400011BF _ 48: 8D. 15, 00000003(rel)
        jmp     qword ptr [rdx+rax*8]                   ; 400011C6 _ FF. 24 C2

?_024   label qword                                     ; switch/case jump table
        dq Unnamed_80000000_0                           ; 400011C9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011D1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011D9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011E1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011E9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011F1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400011F9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001201 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001209 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001211 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001219 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001221 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001229 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001231 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001239 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001241 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001249 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001251 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001259 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001261 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001269 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001271 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001279 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001281 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001289 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001291 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 40001299 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012A1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012A9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012B1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012B9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012C1 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012C9 _ 0000000140001173 (d)
        dq Unnamed_80000000_0                           ; 400012D1 _ 000000014000117D (d)
        dq Unnamed_80000000_0                           ; 400012D9 _ 0000000140001187 (d)
        dq Unnamed_80000000_0                           ; 400012E1 _ 0000000140001191 (d)
        dq Unnamed_80000000_0                           ; 400012E9 _ 000000014000119B (d)

    db 00 24 01 24 02 24 24 24 24 03 24 04 24 24 05 24 24 24 06 24 24 24
    db 24 24 07 24 24 24 24 24 24 08 24 24 24 24 24 24 24 09 24 0a 24 0b
    db 24 24 0c 24 24 24 24 0d 24 24 0e 24 24 24 0f 24 10 24 24 11 24 24
    db 24 12 24 24 24 24 24 24 24 24 13 24 24 14 24 24 15 24 16 24 17 24
    db 18 24 19 24 1a 24 1b 24 1c 24 1d 24 24 24 24 24 24 24 24 24 24 24
    db 24 24 24 24 24 24 24 24 24 24 24 1e 24 1f 24 24 24 24 24 24 24 24
    db 24 24 24 20 21 22 23 b8 44
   
Cod-Father

jj2007

Quote from: habran on May 17, 2016, 01:58:39 PM
Thanks jj2007 :biggrin:
HJWasm32 has to deal with less code so it can be the reason,
but I suspect that your machine is more experienced in running 32 bit and hence the speed ;)
I have here example how much has the .SWITCH block being improved:

I would argue about the "more code" logic if my 27k lines of code consisted significantly of .switch structures, but for compatibility reasons I am still using good ol' Switch_ (remind me to set up a speed & size comparison between Switch_ and .switch ...)

But the "more experienced in running 32 bit" argument is certainly logical :lol:

TWell

#4
@jj2007
here is PellesC 8 x64 version for speed test.

jj2007

@TWell: library build exactly the same as HJWasm32, RichMasm a bit faster:
OxPT_Assembler JWasm ; 880 ms
OxPT_Assembler HJWasm32 ; 820 ms
OxPT_Assembler HJWasm64 ; 820 ms
OxPT_Assembler HJwasm64poc ; 770 ms

habran

jj2007,
Test this one please
Cod-Father

jj2007

Quote from: habran on May 18, 2016, 06:15:47 AM
jj2007,
Test this one please

As fast as the 32-bit version with the RichMasm source,
but with the library, the 32-bit version is exactly 50% faster.

TWell

My test with m32lib *.asm files
HJWasm64.exe -c -coff -q \masm32\m32lib\*.asm

HJWasm32.exe 16.982s
HJWasmGcc.exe 16.712s
HJWasm64poc.exe 21.224s
HJWasm.exe 29.547s
HJWasm64.exe 30.14s
This is odd :icon_confused:

habran

OK, last one was built with  VS15 with full optimization
this one is built with GCC via C:B
let see which one is faster
Cod-Father

jj2007

This one, MB library:
last one 2.77 secs (version 504866 bytes, 18 May)
32-bit 3.15 secs (version 361472 bytes, 16 May)

VS15 has fantastic optimisations :eusa_boohoo:

Btw the last one loads remarkably well with OllyDbg, a well-known 32-bit debugger 8)

habran

Does that mean that GCC is the best version?
Cod-Father

TWell

#12
32-bit gcc version is fast.
m32lib again with another PC.
HJWasmGcc.exe    7.368s 7.659s
HJWasm32.exe     9.153s 9.729s
HJWasm64poc.exe  10.626s 10.664s
HJWasm64Gcc.exe  16.941s 17.214s

64-bit not so fast, compiled with v 5 with option -O2
@SET SRC=..\HJWasm-master
@SET CC=gcc -c -O2 -m64 -I..\HJWasm-master\H -DWIN64=1
@REM hjwasm64gcc.exe:
for %%c in (%SRC%\*.c) do %CC% %%c

gcc -s main.o apiemu.o assemble.o assume.o atofloat.o backptch.o bin.o branch.o cmdline.o codegen.o coff.o condasm.o context.o cpumodel.o data.o dbgcv.o directiv.o elf.o end.o equate.o errmsg.o expans.o expreval.o extern.o fastpass.o fixup.o fpfixup.o hll.o input.o invoke.o label.o linnum.o listing.o loop.o lqueue.o macro.o mangle.o memalloc.o msgtext.o omf.o omffixup.o omfint.o option.o parser.o posndir.o preproc.o proc.o queue.o reswords.o safeseh.o segment.o simsegm.o string.o symbols.o tbyte.o tokenize.o types.o -o hjwasm64gcc.exe

@DEL *.o
Is in my test something wrong :icon_confused:

habran

I have built mine GCC with -O3 and you can see a reduction in size
are you saying that -O2 is producing faster code than -O3?

I can also see that Pelle's C is producing even less code than GCC
Are you sure that HJWasmPoc.64 is fastest 64 bit?

Let show only 64 bit speed with all versions
Cod-Father

jj2007

Quote from: habran on May 18, 2016, 05:01:55 PMLet show only 64 bit speed with all versions

OK, but don't distort the competition by smuggling in (Reply #9) 32-bit versions called HJWasm64 :eusa_naughty:

GCC yes, but no doping please :t