The MASM Forum

Projects => Rarely Used Projects => Archival JWASM postings => Topic started by: habran on November 25, 2014, 07:19:31 AM

Title: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:19:31 AM
Here is the main folder with source files and Visual Studio 2013 project
I have fixed bugs and it suppose to run in 32bit and 64bit in any option
Remember that this is my version with all the goodies inside (I will add an detailed manual later)
so, if you want to access them, you should use for 64 bit:
Code: [Select]
option casemap : none
option win64 : 11
option frame : auto
option stackbase : rsp
Beware that you need H folder in the post under for successful compilation
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:21:37 AM
Here is a folder with headers
decompress it and drop in a main folder
When you open the project you will have to change the:
Project->Properties->C/C++->General->Additional Include Directories:C:\Users\Hn\Desktop\JWasm2014AVX2\H
to your location
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 06:06:19 PM
Goodies added to this version:
PRE-EXISTING FLAG CONDITIONS (dedndave was the godfather to these children)
signed jumps
   LESS?             JGE  skip
   !LESS?            JL    skip
   GREATER?      JLE  skip
  !GREATER?      JG   skip
unsigned missing jumps
   ABOVE?         JBE  skip
   !ABOVE?        JA   skip
;//----------------------------------------------------------------------------------
BUILT IN .FOR AND .ENDFOR C-LIKE HLL LOOP
The first difference is ';' is replaced with '¦' which is character 0A6h or 166
to type it hold ALT down and type 221 and than release ALT
The second difference is that it is highly optimised and runs with the lightning speed
initializers and counters:
=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
condition opperators:
==,!=,> ,< ,>=,<=,&&,||,& ,!,ZERO?,CARRY?,SIGN?,PARITY?,OVERFLOW?,LESS?,GREATER?,ABOVE?

 E.G.  eax+=10   ebx <<= 16 (shl) ecx >>= 8 (shr)
here is how it can be used:
Code: [Select]
  .for (edx=88,ecx=4¦eax != 24 && hWnd > lParam || ebx <= 20 || ebx >= 3¦eax=23,edx=24,ebx++)
nop
  .endfor
   
Code: [Select]
.for (¦r8¦r8++,[rcx].RECT.top=eax)
    nop   
    nop           
    .if (rax)                           
     .continue               
    .endif
    mov[rcx], dl
  .endfor               

 
Code: [Select]
     
;forever loop
.for (¦¦)
.break .if eax
.endfor

;//----------------------------------------------------------------------------------
HOMING SPACE
Although the first four parameters are passed via registers, there is still space allocated on the stack for these four parameters. This is called the  parameter homing space and is used to store parameter values if either the
function accesses the parameters by address instead of by value or if the function is compiled with the homeparams flag. The minimum size of this homing space is 0x20 bytes or four 64-bit slots, even if the function takes less than  4 parameters. When the homing space is not used to store parameter values, the JWasm uses it to save non-volatile registers.

00000000`ff4f34bb mov     qword ptr [rax+8],rbx
00000000`ff4f34bf mov     qword ptr [rax+10h],rbp
00000000`ff4f34c3 mov     qword ptr [rax+18h],rsi
00000000`ff4f34c7 mov     qword ptr [rax+20h],rdi
00000000`ff4f34cb push    r12
00000000`ff4f34cd sub     rsp,70h

Auto save first 4 registers will not save unused register

If a procedure doesn't have invoke it will not unnecessarily allocate the homing space
If a procedure doesn't have locals FRAME will not be created
so you will not need to use:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

;//----------------------------------------------------------------------------------
INVOKE OPTIMIZATION
If invoke has in first 4 parameters FALSE,NULL or 0 it will not assemble to MOVE REG,0
but XOR REG,REG
;//----------------------------------------------------------------------------------
AVX2 IMPLEMENTED




Title: Re: JWasmAVX2 source
Post by: jj2007 on November 25, 2014, 06:32:26 PM
INVOKE OPTIMIZATION
If invoke has in first 4 parameters FALSE,NULL or 0 it will not assemble to MOVE REG,0
but XOR REG,REG

Interesting - we often do that "by hand" :icon14:
Can you give an example?
Which reg is being used? What if coder wants to pass a value with this register?
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:09:45 PM
Here it is:
Code: [Select]
invoke testproc5, NULL,FALSE,NULL, 0,0, rdx
000000013FB618F0 33 C9                xor         ecx,ecx 
000000013FB618F2 33 D2                xor         edx,edx 
000000013FB618F4 45 33 C0             xor         r8d,r8d 
000000013FB618F7 45 33 C9             xor         r9d,r9d 
000000013FB618FA 48 C7 44 24 20 00 00 00 00 mov         qword ptr [rsp+20h],0 
000000013FB61903 48 89 54 24 28       mov         qword ptr [rsp+28h],rdx 
000000013FB61908 E8 76 00 00 00       call        testproc5 (013FB61983h) 

So, not only it will be xor-ed but you can than use it for zeros in next parameters
pay attention to rdx being reused for zero in the sixth parameter

and now I will use it also in fifth parameter have look at this:
Code: [Select]
invoke testproc5, NULL,FALSE,NULL, 0,rdx, rdx
000000013F8C18F0 33 C9                xor         ecx,ecx 
000000013F8C18F2 33 D2                xor         edx,edx 
000000013F8C18F4 45 33 C0             xor         r8d,r8d 
000000013F8C18F7 45 33 C9             xor         r9d,r9d 
000000013F8C18FA 48 89 54 24 20       mov         qword ptr [rsp+20h],rdx 
000000013F8C18FF 48 89 54 24 28       mov         qword ptr [rsp+28h],rdx 
000000013F8C1904 E8 76 00 00 00       call        testproc5 (013F8C197Fh)

MIRACLE!!! isn't it ;)

I cold have used rcx instead or r8 :biggrin:

Quote
Which reg is being used? What if coder wants to pass a value with this register?

it will be zeroed only if it holds zero otherwise it will contain the value of the parameter
I gave more intelligence to JWasm :t
Title: Re: JWasmAVX2 source
Post by: Gunther on November 25, 2014, 07:16:48 PM
Hi habran,

good idea for all the macro fans.  :t

By the way, I've checked the AVX2 code generation with jWasm (counter check via YASM). It works well and generates the same machine code.  :t

Gunther
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:21:40 PM
Thanks Gunther :t
That means that we have now the best assembler on this planet :biggrin:
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:26:20 PM
Quote
Interesting - we often do that "by hand" :icon14:
I hope that doesn't mean something rude ::)
if it does be aware of the danger: you can acquire a blindness :bgrin: 
Title: Re: JWasmAVX2 source
Post by: Gunther on November 25, 2014, 07:31:41 PM
Habran,

That means that we have now best assembler on this planet :biggrin:

I would say nearly. The DOS version is a bit out of date. I'm not sure about the other platforms (Linux, BSD, OS/2).

Gunther
Title: Re: JWasmAVX2 source
Post by: habran on November 25, 2014, 07:40:04 PM
you are just being to polite my friend :biggrin:
Title: Re: JWasmAVX2 source
Post by: Gunther on November 25, 2014, 10:17:56 PM
you are just being to polite my friend :biggrin:

No it's just a summary of the state, not more and not less.

Gunther
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 26, 2014, 12:13:43 AM

Quote
That means that we have now best assembler on this planet
He need some improvements."general failure" with version generated with source code and an unchanged code who was good before change of compiler.The first 64 compiler you posted was better than the new.
 
 
Title: Re: JWasmAVX2 source
Post by: jj2007 on November 26, 2014, 01:35:35 AM

000000013FB618F2 33 D2                xor         edx,edx 
000000013FB61903 48 89 54 24 28       mov         qword ptr [rsp+28h],rdx 

How long is the and qword ptr [rsp+x] encoding? I'm not yet in 64-bit, so I can't test it...

0040100F   ³.  33C9           xor ecx, ecx
00401011   ³.  894C24 10      mov [esp+10], ecx
00401015   ³.  836424 10 00   and dword ptr [esp+10], 00000000


Another option would be to use the shorter rbp encodings instead of rsp:

0040101A   ³.  894D 10        mov [ebp+10], ecx
0040101D   ³.  8365 10 00     and dword ptr [ebp+10], 00000000
Title: Re: JWasmAVX2 source
Post by: Biterider on November 26, 2014, 04:12:47 AM
Thanks Habran!

Biterider
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 06:11:25 AM
Biterider, do you have the same problem as ToutEnMasm?
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 06:19:22 AM
jj2007 here you are:
Code: [Select]
and qword ptr [store],15
000000013F1911C9 48 83 A4 24 88 00 00 00 0F and         qword ptr [store],0Fh
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 06:39:05 AM
ToutEnMasm I have tested source before I posted it here an I have tested it 1 minute before
and it runs flawlessly :biggrin:
I suspect that you built Debug version
Try to build Release version with Optimization: Maximize Speed (/O2) 
here is my last 64bit build from this source
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 06:55:52 AM
I have spotted that some people downloaded sources without H folder
If you don't use this headers you will not have AVX2 built in
Do not build Debug version but Release version
Debug version of JWasm in 64bit has got a bug from original source
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 07:42:54 AM
jj2007, using ebp or rbp for a stack frame is not shorter but apposite because of the overhead
Code: [Select]
00941097 55                   push        ebp 
00941098 8B EC                mov         ebp,esp
................
00941227 8B E5                mov         esp,ebp 
00941229 5D                   pop         ebp 
0094122A C2 10 00             ret         10h 

let alone that ebp is not available for use ;)
Title: Re: JWasmAVX2 source
Post by: jj2007 on November 26, 2014, 12:43:26 PM
jj2007 here you are:
Code: [Select]
and qword ptr [store],15
000000013F1911C9 48 83 A4 24 88 00 00 00 0F and         qword ptr [store],0Fh

Oops, 9 bytes??? Intel is crazy, and dword ptr [eax+10h], 15 costs only 4 bytes :(
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 01:29:47 PM
it is 5 bytes on 64 bit sistem when running 32 bit APS
Code: [Select]
00E7109D 83 64 24 1C 0F       and         dword ptr [bAVX],0Fh
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 26, 2014, 04:41:13 PM
Hello,
The version you have posted in #16,made the same thing.
Quote
Win64_8.asm: 376 lines, 3 passes, 0 ms, 0 warnings, 0 errors
Error A2168: General Failure
The first version you have posted in #1,work for me.She is in the JaWasm zip
with vc express 2013 i have further tests with various envirronnements (AMD64,...),aways same answer.
The compile i have made with your source codes is a release version with O2,I have made a test with your own project files also.
Quote
Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 05:46:28 PM
ToutEnMasm I don't know what to say because no one else complained
I am curious if anyone else had the same problem as you
I have rebuild and tested binaries and no problem here
Use that version which works for you until we see if other people have the same problem
It could be posible that JWasm.targets are wrong
Title: Re: JWasmAVX2 source
Post by: habran on November 26, 2014, 05:58:54 PM
here are JWasm targets

they suppose to be put here:C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 27, 2014, 01:00:48 AM
Here the better information I can have on the failure main.c line 127 (do while):

it is in isctype.c line 56
Quote
extern "C" int __cdecl _chvalidator(
        int c,
        int mask
        )
{
        _ASSERTE(c >= -1 && c <= 255);           //line 56 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        return _chvalidator_l(NULL, c, mask);
}
Title: Re: JWasmAVX2 source
Post by: habran on November 27, 2014, 05:50:39 AM
Code: [Select]
/***
* __chvalidator
*
* Purpose:
*       This function is called by character testing functions in debug
*       versions. This function test for validation of c as character.
*       For improvement in performance, it is not used in non-debug
*       version.  It is available in the static single-thread non-debug
*       build, though, just in case C code that includes ctype.h is compiled
*       /D_DEBUG /ML.
*
*******************************************************************************/

It looks like you are building debug version :icon_eek:
in main.c line 124
try to use instead of:
Code: [Select]
strcpy( &fname[dirsize], finfo.name );this:
Code: [Select]
wcscpy( &fname[dirsize], finfo.name );
Title: Re: JWasmAVX2 source
Post by: habran on November 27, 2014, 06:13:21 AM
ToutEnMasm, you are probably using your version of include files for assembling
I would strongly suggest you to use WinInc from Japhet's sight until you are sure that your version is working fine :biggrin:
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 27, 2014, 08:42:24 AM

I have build a debug to try find the bug.
There is no include file in the sample.
Title: Re: JWasmAVX2 source
Post by: habran on November 27, 2014, 11:38:33 AM
You need include when you assemble your ASM sources, that's what JWasm.exe is for
I suspect that the error is in your SDK that's why you have general failure error
because you can build JWasm from C sources but you can not build your ASM project :biggrin:
You use VC13 to COMPILE C sources and JWasm.exe to  ASSEMBLE ASM sources
As you can see no one else has problem but you ;)
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 27, 2014, 05:59:40 PM
Quote
You need include when you assemble your ASM sources
Wrong!
It is the sample provided with the  JWasm212bw.zip
All defines are with the code

Without any source code I get this message in windbg
Quote
-- LuaPriv initialized--
failed to set heap information 00000057
VERIFIER STOP 000000000000D02F: pid 0x186C: FatalExit was called


Quote

;--- create a 64-bit binary with -pe cmdline option
;---
;---   JWasm -pe Win64_8.asm
comment µ
    .x64                ; -pe requires to set cpu, model & language
    .model flat, fastcall

    option casemap:none
    option frame:auto   ; generate SEH-compatible prologues and epilogues
    option win64:3      ; init shadow space, reserve stack at PROC level
µ
;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src\isctype.c
;comment µ
    .x64                ; -pe requires to set cpu, model & language
    .model flat, fastcall

option casemap : none
option win64 : 7
option frame : auto
option stackbase : rsp
    .xmm


.NOLIST
includelib kernel32.lib
includelib user32.lib
includelib gdi32.lib

;--- resource IDs
IDR_MENU1   EQU 100
IDR_BITMAP1 EQU 101
IDM_EXIT    EQU 1000

NULL      equ 0
LPSTR     typedef ptr
LPVOID    typedef ptr
UINT      typedef DWORD
BOOL      typedef DWORD

;--- winbase definitions
HINSTANCE typedef ptr

;--- winuser definitions
HWND      typedef ptr
HMENU     typedef ptr
HICON     typedef ptr
HBRUSH    typedef ptr
HCURSOR   typedef ptr
HDC       typedef ptr
HBITMAP   typedef ptr
WPARAM    typedef ptr
LPARAM    typedef QWORD

WS_OVERLAPPEDWINDOW equ 0CF0000h
CW_USEDEFAULT  equ 80000000h
SW_SHOWDEFAULT equ 10
SW_SHOWNORMAL  equ 1
IDC_ARROW      equ 32512
IDI_APPLICATION equ 32512
CS_VREDRAW     equ 1
CS_HREDRAW     equ 2
COLOR_WINDOW   equ 5

WM_DESTROY     equ 2
WM_PAINT       equ 000Fh
WM_COMMAND     equ 0111h

proto_WNDPROC typedef proto :HWND,:QWORD,:WPARAM,:LPARAM
WNDPROC typedef ptr proto_WNDPROC

WNDCLASSEXA struct 8
cbSize          DWORD   ?
style           DWORD   ?
lpfnWndProc     WNDPROC ?
cbClsExtra      DWORD   ?
cbWndExtra      DWORD   ?
hInstance       HINSTANCE ?
hIcon           HICON   ?
hCursor         HCURSOR ?
hbrBackground   HBRUSH  ?
lpszMenuName    LPSTR   ?
lpszClassName   LPSTR   ?
hIconSm         HICON   ?
WNDCLASSEXA ends

POINT   struct
x   SDWORD  ?
y   SDWORD  ?
POINT   ends

MSG struct 8
hwnd    HWND    ?
message DWORD   ?
wParam  WPARAM  ?
lParam  LPARAM  ?
time    DWORD   ?
pt      POINT   <>
MSG ends

RECT struct
left    SDWORD  ?
top     SDWORD  ?
right   SDWORD  ?
bottom  SDWORD  ?
RECT ends

PAINTSTRUCT struct 8
hdc         HDC  ?
fErase      BOOL ?
rcPaint     RECT <>
fRestore    BOOL ?
fIncUpdate  BOOL ?
rgbReserved BYTE 32 dup (?)
PAINTSTRUCT ends

;--- wingdi definitions

DIB_RGB_COLORS  EQU 0
SRCCOPY         EQU 00CC0020h

HGDIOBJ  typedef ptr

BITMAPINFOHEADER struct
biSize          DWORD   ?
biWidth         SDWORD  ?
biHeight        SDWORD  ?
biPlanes        WORD    ?
biBitCount      WORD    ?
biCompression   DWORD   ?
biSizeImage     DWORD   ?
biXPelsPerMeter SDWORD  ?
biYPelsPerMeter SDWORD  ?
biClrUsed       DWORD   ?
biClrImportant  DWORD   ?
BITMAPINFOHEADER ends

    option dllimport:<kernel32.dll>
GetModuleHandleA proto :LPSTR
GetCommandLineA  proto
ExitProcess      proto :UINT

    option dllimport:<user32.dll>
BeginPaint       proto :HWND, :ptr PAINTSTRUCT
CreateWindowExA  proto :DWORD, :LPSTR, :LPSTR, :DWORD, :SDWORD, :SDWORD, :SDWORD, :SDWORD, :HWND, :HMENU, :HINSTANCE, :LPVOID
DefWindowProcA   proto :HWND, :UINT, :WPARAM, :LPARAM
DestroyWindow    proto :HWND
DispatchMessageA proto :ptr MSG
EndPaint         proto :HWND, :ptr PAINTSTRUCT
GetClientRect    proto :HWND, :ptr RECT
GetMessageA      proto :ptr MSG, :HWND, :SDWORD, :SDWORD
LoadBitmapA      proto :HINSTANCE, :LPSTR
LoadCursorA      proto :HINSTANCE, :LPSTR
LoadIconA        proto :HINSTANCE, :LPSTR
PostQuitMessage  proto :SDWORD
RegisterClassExA proto :ptr WNDCLASSEXA
ShowWindow       proto :HWND, :SDWORD
TranslateMessage proto :ptr MSG
UpdateWindow     proto :HWND

    option DLLIMPORT:<gdi32.dll>
BitBlt             proto :HDC, :DWORD, :DWORD, :DWORD, :DWORD, :HDC, :DWORD, :DWORD, :DWORD
CreateCompatibleDC proto :HDC
DeleteDC           proto :HDC
GetDIBits          proto :HDC, :HBITMAP, :DWORD, :DWORD, :ptr, :ptr BITMAPINFO, :DWORD
SelectObject       proto :HDC, :HGDIOBJ
    option dllimport:none

WinMain proto :HINSTANCE, :HINSTANCE, :LPSTR, :UINT

    .data

ClassName db "SimpleWinClass",0
AppName  db "Bitmap rendering",0

    .data?

hInstance HINSTANCE ?
hBitmap   HBITMAP ?
CommandLine LPSTR ?

    .code

;WinMainCRTStartup proc FRAME
start:
   .LISTALL
   mov eax,sizeof HWND
   .NOLIST
    invoke GetModuleHandleA, NULL
    mov    hInstance, rax
    invoke GetCommandLineA
    mov    CommandLine, rax
    invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
    invoke ExitProcess, eax

;WinMainCRTStartup endp

WinMain proc FRAME hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:UINT

    LOCAL wc:WNDCLASSEXA
    LOCAL msg:MSG
    LOCAL hwnd:HWND

    invoke LoadBitmapA, hInst, IDR_BITMAP1
    mov   hBitmap, rax

    mov   wc.cbSize, SIZEOF WNDCLASSEXA
    mov   wc.style, CS_HREDRAW or CS_VREDRAW
    lea   rax, [WndProc]
    mov   wc.lpfnWndProc, rax
    mov   wc.cbClsExtra, 0
    mov   wc.cbWndExtra, 0
    mov   rcx, hInst
    mov   wc.hInstance, rcx
    mov   wc.hbrBackground, COLOR_WINDOW+1
    mov   wc.lpszMenuName, IDR_MENU1
    lea   rax, [ClassName]
    mov   wc.lpszClassName, rax
    invoke LoadIconA, NULL, IDI_APPLICATION
    mov   wc.hIcon, rax
    mov   wc.hIconSm, rax
    invoke LoadCursorA, NULL, IDC_ARROW
    mov   wc.hCursor,rax
    invoke RegisterClassExA, addr wc
    invoke CreateWindowExA, NULL, ADDR ClassName, ADDR AppName,
           WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
           CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL, NULL,
           hInst, NULL
    mov   hwnd,rax
    invoke ShowWindow, hwnd, SW_SHOWNORMAL
    invoke UpdateWindow, hwnd
    .while (1)
        invoke GetMessageA, ADDR msg, NULL, 0, 0
        .break .if (!eax)
        invoke TranslateMessage, ADDR msg
        invoke DispatchMessageA, ADDR msg
    .endw
    mov   rax, msg.wParam
    ret
WinMain endp

WndProc proc FRAME hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

local hdc2:HDC
local ps:PAINTSTRUCT
local rect:RECT
local bmi:BITMAPINFOHEADER

    .if edx == WM_DESTROY
        invoke PostQuitMessage, NULL
        xor rax,rax
    .elseif edx == WM_COMMAND
        .if wParam == IDM_EXIT
            invoke DestroyWindow, hWnd
        .endif
        xor eax, eax
    .elseif edx == WM_PAINT
        invoke BeginPaint, hWnd, addr ps
        invoke CreateCompatibleDC, ps.hdc
        mov hdc2, rax
        invoke SelectObject, hdc2, hBitmap
        mov bmi.biSize, sizeof BITMAPINFOHEADER
        mov bmi.biBitCount, 0
        invoke GetDIBits, hdc2, hBitmap, 0, 0, 0, addr bmi, DIB_RGB_COLORS
        invoke GetClientRect, hWnd, addr rect
        mov r8d, rect.right
        sub r8d, bmi.biWidth
        jnc @F
        xor r8d, r8d
@@:
        shr r8d, 1
        mov r9d, rect.bottom
        sub r9d, bmi.biHeight
        jnc @F
        xor r9d, r9d
@@:
        shr r9d, 1
        invoke BitBlt, ps.hdc, r8d, r9d, bmi.biWidth, bmi.biHeight, hdc2, 0, 0, SRCCOPY
        invoke DeleteDC, hdc2
        invoke EndPaint, hWnd, addr ps

        xor eax,eax
    .else
        invoke DefWindowProcA, rcx, edx, r8, r9
    .endif
    ret
WndProc endp

if 1 ;for -pe

RT_BITMAP EQU 2
RT_MENU   EQU 4

;--- menu resource flags
MF_POPUP   EQU 10h
MF_END     EQU 80h

IMAGE_RESOURCE_DIRECTORY struct
Characteristics      DWORD ?
TimeDateStamp        DWORD ?
MajorVersion         WORD  ?
MinorVersion         WORD  ?
NumberOfNamedEntries WORD  ?
NumberOfIdEntries    WORD  ?
IMAGE_RESOURCE_DIRECTORY ends

IMAGE_RESOURCE_DIRECTORY_ENTRY struct
union
r0      RECORD NameIsString:1, NameOffset:31
Name_   DWORD   ?
Id      WORD    ?
ends
union
OffsetToData DWORD   ?
r1           RECORD   DataIsDirectory:1, OffsetToDirectory:31
ends
IMAGE_RESOURCE_DIRECTORY_ENTRY ends

IMAGE_RESOURCE_DATA_ENTRY struct
OffsetToData DWORD ?
Size_        DWORD ?
CodePage     DWORD ?
Reserved     DWORD ?
IMAGE_RESOURCE_DATA_ENTRY ends

    option dotname

.rsrc segment dword read FLAT public 'RSRC'

;--- define menu IDR_MENU1 and bitmap IDR_BITMAP1

;--- root level: enum the resource types
      IMAGE_RESOURCE_DIRECTORY <0,0,0,0,0,2>
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <RT_BITMAP>, <SECTIONREL bms   + 80000000h> >
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <RT_MENU>,   <SECTIONREL menus + 80000000h> >

;--- second level: enum the IDs of resource type X
bms   IMAGE_RESOURCE_DIRECTORY <0,0,0,0,0,1>
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <IDR_BITMAP1>, <SECTIONREL bm1   + 80000000h> >
menus IMAGE_RESOURCE_DIRECTORY <0,0,0,0,0,1>
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <IDR_MENU1>,   <SECTIONREL menu1 + 80000000h> >

;--- third level: enum the languages of ID X
bm1   IMAGE_RESOURCE_DIRECTORY <0,0,0,0,0,1>
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <409h>, <SECTIONREL bm1_l1> >
menu1 IMAGE_RESOURCE_DIRECTORY <0,0,0,0,0,1>
      IMAGE_RESOURCE_DIRECTORY_ENTRY < <409h>, <SECTIONREL m1_l1> >

;--- last level: define the resource data
;--- data for menu IDR_MENU1, language 409h
m1_l1 IMAGE_RESOURCE_DATA_ENTRY <IMAGEREL m1_l1_data, size_m1_l1, 0, 0>
m1_l1_data dw 0,0   ;menu header
    dw MF_POPUP or MF_END, '&','F','i','l','e',0
    dw MF_END, IDM_EXIT,   'E','&','x','i','t',0
size_m1_l1 equ $ - m1_l1_data
    align 4

;--- data for bitmap IDR_BITMAP1
bm1_l1 IMAGE_RESOURCE_DATA_ENTRY <IMAGEREL bm1_l1_data, size_bm1_l1, 0, 0>
bm1_l1_data label word
    incbin <Win32_8.bmp>,14   ;skip bitmap file header
size_bm1_l1 equ $ - ( bm1_l1_data )

.rsrc ends

;--- set /subsystem:windows
;--- the PE header is stored in section .hdr$2
    option dotname
.hdr$2 segment DWORD FLAT public 'HDR'
    org 5Ch ;position to IMAGE_NT_HEADER64.OptionalHeader.Subsystem
    dw 2    ;2=subsystem windows
.hdr$2 ends

endif

end start ;WinMainCRTStartup

Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 27, 2014, 07:27:16 PM

Debugging in visual studio 2013,i get  "jwasm had triggered a breakpoint"
http://stackoverflow.com/questions/10172436/c-error-on-ms-visual-studio-windows-has-triggered-a-breakpoint-in-javaw-exe (http://stackoverflow.com/questions/10172436/c-error-on-ms-visual-studio-windows-has-triggered-a-breakpoint-in-javaw-exe)
Title: Re: JWasmAVX2 source
Post by: habran on November 27, 2014, 09:03:31 PM
Sorry, you are on your own now
I can't help you there :(
did you try to build 32 bit JWasm.exe?
Title: Re: JWasmAVX2 source
Post by: habran on November 27, 2014, 11:54:32 PM
I copied source from your last post pasted it in my project and built flawlessly and it worked without any change
Title: Re: JWasmAVX2 source
Post by: Gunther on November 28, 2014, 12:50:49 AM
I copied source from your last post pasted it in my project and built flawlessly and it worked without any change

For me too.

Gunther
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 28, 2014, 12:53:49 AM
If I try to build a 32 bit,I get two problems,in another source code
.while
.continue         ;not accepted,unknown adress ;it work with the normal 32 jwasm
and an access violation in ntdll at run
Quote
ntdll: access violation
_RtlReAllocateHeap@16:
771ECB60  mov         edi,edi 
771ECB62  push        ebp 
771ECB63  mov         ebp,esp 
771ECB65  and         esp,0FFFFFFF8h 
771ECB68  sub         esp,7Ch 
771ECB6B  mov         eax,dword ptr ds:[77283250h] 
771ECB70  xor         eax,esp 
771ECB72  mov         dword ptr [esp+78h],eax 
771ECB76  mov         ecx,dword ptr [ebp+0Ch] 
771ECB79  push        ebx 
771ECB7A  mov         ebx,dword ptr [ebp+10h] 
771ECB7D  mov         dword ptr [esp+18h],0 
771ECB85  mov         dword ptr [esp+14h],0 
771ECB8D  push        esi 
771ECB8E  mov         esi,dword ptr [ebp+14h] 
771ECB91  mov         dword ptr [esp+14h],esi 
771ECB95  push        edi 
771ECB96  mov         edi,dword ptr [ebp+8] 
771ECB99  test        ebx,ebx 
771ECB9B  je          string L"\\??\\%C:"+34CFDh (77208D3Dh) 
771ECBA1  mov         eax,dword ptr [edi+44h]   ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Title: Re: JWasmAVX2 source
Post by: habran on November 28, 2014, 06:31:04 AM
Thanks Gunther :biggrin:
 that proves that nothing is wrong with sources :t
ToutEnMasm, the project was created with:
Microsoft Visual Studio Community Professional 2013 for Desktop
Version 12.0.31101 Update 4
Microsoft Visual Studio Community 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework Version 4.5.50938

If you have Windows 8, you have a different version than this
Tray to create new project and than add sources
Title: Re: JWasmAVX2 source
Post by: Gunther on November 28, 2014, 06:44:40 AM
Thanks Gunther :biggrin:
 that proves that nothing is wrong with sources :t

Yes, I think the sources are okay.

Gunther
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 28, 2014, 06:52:55 AM

Is there need of the ALIAS1.lib in 64 bits ?
Your binaries made the same thing than mine???????.
Title: Re: JWasmAVX2 source
Post by: habran on November 28, 2014, 07:19:50 AM
Command Line for link:
Quote
/OUT:"C:\Users\Hn\Desktop\JWasm12avx2\JWasm\x64\Release\JWasm.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Users\Hn\Desktop\JWasm12avx2\JWasm\x64\Release\JWasm.pdb" /DYNAMICBASE /MACHINE:X64 /INCREMENTAL:NO /PGD:"C:\Users\Hn\Desktop\JWasm12avx2\JWasm\x64\Release\JWasm.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\JWasm.exe.intermediate.manifest" /ERRORREPORT:PROMPT /TLBID:1

Command Line for C
Quote
/GS- /TC /W2 /Zc:wchar_t /I"C:\Users\Hn\Desktop\JWasm12avx2\H" /Gm- /O2 /Fd"x64\Release\vc120.pdb" /fp:precise /Zp8 /D "WIN64" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /MT /Fa"x64\Release\" /nologo /Fo"x64\Release\" /FAs /Fp"x64\Release\JWasm.pch"

I don't see ALIAS1.lib here
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 28, 2014, 07:40:24 PM
found
There is cases where _findfirst return 1,and it is not a handle!
The modify below run without problem
Quote
int main( int argc, char **argv )
   ...........
   intptr_t    fh; //long
   int resultat =0;
   ................
        do {
            /* v2.12: _splitpath()/_makepath() removed */
            //_makepath( fname, drv, dir, finfo.name, NULL );
            //DebugMsg(("main: _makepath(\"%s\", \"%s\", \"%s\")=\"%s\"\n", drv, dir, finfo.name, fname ));
            strcpy( &fname[dirsize], finfo.name );
            DebugMsg(("main: fname=%s\n", fname ));
            rc = AssembleModule( fname );  /* assemble 1 module */
         //-c -coff -pe H:\64bits\fenetre\Win64_8.asm
         if (fh != 1) // only one file
         {
            resultat = _findnext(fh, &finfo);
         } // only one file
         else
         {
            resultat = -1;
         }
   } while (resultat != -1);
   ...................

Title: Re: JWasmAVX2 source
Post by: jj2007 on November 28, 2014, 08:56:59 PM
   intptr_t    fh; //long
   int resultat =0;
   ................
        do {
            /* v2.12: _splitpath()/_makepath() removed */
            //_makepath( fname, drv, dir, finfo.name, NULL );
            //DebugMsg(("main: _makepath(\"%s\", \"%s\", \"%s\")=\"%s\"\n", drv, dir, finfo.name, fname ));
            strcpy( &fname[dirsize], finfo.name );
            DebugMsg(("main: fname=%s\n", fname ));
            rc = AssembleModule( fname );  /* assemble 1 module */
         //-c -coff -pe H:\64bits\fenetre\Win64_8.asm
         if (fh != 1) // only one file

Where do you set fh? If _findfirst uses FindFirstFile under the hood: "If the function fails, the return value is INVALID_HANDLE_VALUE" - and that is not 1 but rather -1.
Title: Re: JWasmAVX2 source
Post by: habran on November 28, 2014, 10:22:34 PM
Hi ToutEnMasm :biggrin:
I am happy that it works for you and I think that there is no harm to the rest of the code
If I ever encounter that error I will know what to do

Hi jj2007 :biggrin:
here is the answer on your question:
Code: [Select]
#if WILDCARDS
        if ((fh = _findfirst( Options.names[ASM], &finfo )) == -1 ) {
            DebugMsg(("main: _findfirst(%s) failed\n", Options.names[ASM] ));
            EmitErr( CANNOT_OPEN_FILE, Options.names[ASM], ErrnoStr() );
            break;
        }
        /* v2.12: _splitpath()/_makepath() removed */
        //_splitpath( Options.names[ASM], drv, dir, NULL, NULL );
        //DebugMsg(("main: _splitpath(%s): drv=\"%s\" dir=\"%s\"\n", Options.names[ASM], drv, dir ));
        pfn = GetFNamePart( Options.names[ASM] );
        dirsize = pfn - Options.names[ASM];
        memcpy( fname, Options.names[ASM], dirsize );
        do {
            /* v2.12: _splitpath()/_makepath() removed */
            //_makepath( fname, drv, dir, finfo.name, NULL );
            //DebugMsg(("main: _makepath(\"%s\", \"%s\", \"%s\")=\"%s\"\n", drv, dir, finfo.name, fname ));
            strcpy( &fname[dirsize], finfo.name );
            DebugMsg(("main: fname=%s\n", fname ));
            rc = AssembleModule( fname );  /* assemble 1 module */
        } while ( ( _findnext( fh, &finfo ) != -1 ) );
        _findclose( fh );
#else
        rc = AssembleModule( Options.names[ASM] );
#endif
don't you worry, there is nothing wrong with it ;)
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 29, 2014, 02:36:02 AM

If i have no failure with the 64 bits source code now,stay:
Quote
.while TRUE
.............
.continue ;Fichiers.inc(837) : Error A2102: Symbol not defined : @C0000
.elseif  ...
.endw
It is a 32 bit source code compiled with the 64 bit version.
The source code for 32 bits do it,is it possible to do something ?.


Title: Re: JWasmAVX2 source
Post by: habran on November 29, 2014, 06:01:41 AM
ToutEnMasm send me that source code and Fichiers.inc
BTW where did you get Fichiers.inc?
Title: Re: JWasmAVX2 source
Post by: ToutEnMasm on November 29, 2014, 05:43:30 PM
The fichier.inc is one of my source code.

Here is a souce code to test .continue.
The first sources codes you have posted do no error on it.
If you need them,I can post them
Title: Re: JWasmAVX2 source
Post by: habran on November 29, 2014, 08:45:47 PM
Hi ToutEnMasm :biggrin:
Great find :t
It was error in hll.c
I fixed it and I post it here
replace hll.c with this one and rebuild solution
Title: Re: JWasmAVX2 source
Post by: habran on November 29, 2014, 09:16:38 PM
I replaced the folder at the top of this tread
there was a bug in hll.c  in HllExitDir proc in .CONTINUE
fixed and runs fine now
those who don't want to again download whole folder can only replace hll.c with above one in post #45
apologize for inconvenience  :redface: