flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > problem with "data resource" in FASMW 1.67.7

Author
Thread Post new topic Reply to topic
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 27 Aug 2006, 01:50
with the new version of FASMW 1.67.7 I get a message "Error: illegal instruction" on "data resource"
should I use something else instead ?
Post 27 Aug 2006, 01:50
View user's profile Send private message Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 27 Aug 2006, 15:35
actually, it's not from FASMW, but from the new INCLUDE folder, because when I replace it with an old version of this folder, it works
Post 27 Aug 2006, 15:35
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 27 Aug 2006, 17:23
Could you show us your code, to make sure that you are not making a fundamental error?
Post 27 Aug 2006, 17:23
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 27 Aug 2006, 19:07
maybe like exchanging use16, use32, use64 - sometimes has happened to me
Post 27 Aug 2006, 19:07
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 29 Aug 2006, 06:51
I somehow deleted 80% of my HDD (probably a virus), so I can't show the actual code, but this simple dialog program will do I guess :
Code:
include '%include%/win32a.inc'
data import ;section '.import' import data readable writeable
    library kernel32,'KERNEL32.DLL', user32,'USER32.DLL'
    include '%api%\kernel32.inc'
    include '%api%\user32.inc'
end data
data resource ;section '.rsrc' resource data readable
    directory RT_DIALOG,dialogs
    resource dialogs,0,LANG_ENGLISH+SUBLANG_DEFAULT,dialog0
    dialog  dialog0,'DlgEdit',0,0,400,300,WS_VISIBLE+WS_SYSMENU+WS_MAXIMIZEBOX+WS_MINIMIZEBOX+WS_THICKFRAME+DS_CENTER,2,,'Terminal'
        dialogitem 'EDIT','',10,0,0,0,0,WS_VISIBLE+WS_HSCROLL+WS_VSCROLL+ES_AUTOHSCROLL+ES_AUTOVSCROLL+ES_MULTILINE+ES_WANTRETURN;+WS_CHILD
    enddialog
end data
entry $
;        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,0,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,0 

proc DialogProc,hwnd,msg,wparam,lparam
        push    ebx esi edi 
        cmp     [msg], WM_CTLCOLOREDIT
        je      fontcolours
        cmp     [msg], WM_SIZE
        je      wmsize
        cmp     [msg], WM_CLOSE
        je      wmclose 
        xor     eax, eax
 finish: pop     edi esi ebx
        ret

  wmclose:
        invoke  EndDialog,[hwnd],0
        jmp     finish

  fontcolours:
;        invoke  SetTextColor, [wparam], $ffff00
;        invoke  SetBkColor, [wparam], 0    ; test background color (for all lines with text)
;        invoke  CreateSolidBrush, 0       ; background colour for the rest of the lines
        jmp     finish

  wmsize:
        push    TRUE
        mov     eax, [lparam]
        shr     eax, 16
        push    eax
        mov     eax, [lparam]
        and     eax, 0ffffh
        push    eax
        push    0 0
        invoke  GetDlgItem,[hwnd],10
        invoke  MoveWindow,eax
        jmp     finish
endp    
the error appears at the secound line of the code, so I guess my problem is with "data", not with "resource"
Post 29 Aug 2006, 06:51
View user's profile Send private message Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 29 Aug 2006, 06:59
anyway, I am using a previous version of the INCLUDE folder, so I can compile my programs. I just thought that it might be some kind of bug that should be fixed for the next release of FASM.
Post 29 Aug 2006, 06:59
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 29 Aug 2006, 08:37
Exclamation a few errors you should be aware of for starters:
1. You need this at the start of your program
format PE GUI 4.0
entry WINMAIN

2. change 'entry $' to WINMAIN:

3. remove 'data import' and 'data resource', uncomment the 'section' lines

4. in 'wmsize' section, 'MoveWindow' has wrong number of parameters, should have 5 parameters

5. I"d move your resource and import sections to the bottom of your assembly file.

BTW, Fasm works just fine. I've gotten the program to compile but doesn't work correctly, You'll need to do some debugging. Sad
Post 29 Aug 2006, 08:37
View user's profile Send private message Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 29 Aug 2006, 14:05
10x madmatt! I am aware of the above and my eccentric programming Smile (I do this mainly to have less lines in the source, and smaller size of the executable), but it worked this way with the previous version of the include file (with the GDI32.DLL included in the import section). The only problem seemed to be that I didnt had the format directive. With "format PE GUI 4.0" included the program worked perfectly on my computer. tnx again madmatt!
About the 'wmsize' section, the rest of the parameters of 'MoveWindow' are pushed before invoke GetDlgItem so it does not change them. To make it even more complicated, I optimized it to this:
Code:
  wmsize:
        mov     eax, [lparam]
        shr     eax, 16
        push    TRUE eax
        mov     eax, [lparam]
        and     eax, 0ffffh
        invoke  GetDlgItem,[hwnd],10,0,0,eax
        invoke  MoveWindow,eax
        jmp     finish    
Post 29 Aug 2006, 14:05
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 29 Aug 2006, 15:12
madmatt: You don't need to change entry $, I do that all the time and it works Wink also, you CAN put data import, data resource etc. into the flat section (FASM does this).
Post 29 Aug 2006, 15:12
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 31 Aug 2006, 08:28
Just use win32aX.inc for a header and it will work without "format PE" line.
Post 31 Aug 2006, 08:28
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:  


< 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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.