flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > minor bug?

Author
Thread Post new topic Reply to topic
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Just macro compillation bug?
Code:
include 'win32wx.inc'
entry   start

start:
        xor     ebx,ebx

        push    MB_OK OR MB_ICONINFORMATION
        push    _capt
        push    _text
        push    ebx
        call    [MessageBox]

        push    ebx
        call    [ExitProcess]

_capt   DU      'This is a caption',0
_text   DU      'This is a text inside',0


data    import
library kernel32,'kernel32.dll',\
        user32,'user32.dll'

;import  kernel32,\
;        ExitProcess,'ExitProcess'
;import  user32,\
;        MessageBox,'MessageBoxW'
end     data
    


Description:
Download
Filename: Testing.asm
Filesize: 476 Bytes
Downloaded: 142 Time(s)


_________________
Any offers?
Post 31 Oct 2006, 21:15
View user's profile Send private message Reply with quote
Remy Vincent



Joined: 16 Sep 2005
Posts: 155
Location: France
Remy Vincent
FIRST
===>>> push ebx
Well, after a call to MessageBox, HOW ebx can still hold ZERO???? Even viewing the source code of the Operating System (OS), and even being sure that the MESSAGEBOX function is not touching EBX register, what if next version of the OS is not leaving EBX untouched ???...

then
==>>> include '.....'

You forgot to add SET PATH=%PATH%;"""FasmIncludeFolderPath""" to the
usual Auto...BAT file, so the compiler is not able to find the include file

also:........
;import kernel32,\
; ExitProcess,'ExitProcess'
;import user32,\
; MessageBox,'MessageBoxW'
I am 100% sure you will forget to remove de 4 ;;;; of this 4 lines, just because you're used to have a compilation OK with those 4 ;;;; left untouched.. WTFIGO???

_________________
Groups lower your IQ
Post 01 Nov 2006, 00:28
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
this bug is with 1.67.14 FASM.
Remy study calling conventions (stdcall) and take a look at extended includes to know why are they called so.
Post 01 Nov 2006, 07:36
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Remy Vincent, the convention of not changing ebx, edi, esi is a main assumption in Windows Programming. That's how compilers generate code, and that's how Windows kernel behaves even internally. It's the basis, and so you can only trust it. Also, I don't know any examples where ebx, edi or esi were changed after some call to Windows API.
Post 01 Nov 2006, 20:50
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
I still haven't got an answer Sad
Code:
;format  PE GUI 4.0

include 'win32wx.inc'
;entry   start

start:
        xor     ebx,ebx

        push    MB_OK OR MB_ICONINFORMATION
        push    _capt
        push    _text
        push    ebx
        call    [MessageBox]

        push    ebx
        call    [ExitProcess]

_capt   DU      'This is a caption',0
_text   DU      'This is a text inside',0


data    import
library kernel32,'kernel32.dll',\
        user32,'user32.dll'

include 'api\kernel32.inc'
include 'api\user32.inc'
;import  kernel32,\
;        ExitProcess,'ExitProcess'
;import  user32,\
;        MessageBox,'MessageBoxW'
end     data
    

extended includes have such declorations inside:
Code:
macro import lib,[functions]
{ common macro import_#lib \{ import lib,functions \} }

include 'api/kernel32.inc'
include 'api/user32.inc'
include 'api/gdi32.inc'
include 'api/advapi32.inc'
include 'api/comctl32.inc'
include 'api/comdlg32.inc'
include 'api/shell32.inc'
include 'api/wsock32.inc'
    

consequently i don't have to declare "import". If i don't, i get "Undefined symbol", but if i do i get "symbol already defined"!
It's too bad to be truth...

_________________
Any offers?
Post 01 Nov 2006, 21:15
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent
Code:
;format  PE GUI 4.0

include 'win32wx.inc'
entry   start

start:
        xor     ebx,ebx

        push    MB_OK OR MB_ICONINFORMATION
        push    _capt
        push    _text
        push    ebx
        call    [MessageBox]

        push    ebx
        call    [ExitProcess]

_capt   DU      'This is a caption',0
_text   DU      'This is a text inside',0


data    import
library kernel32,'kernel32.dll',\
        user32,'user32.dll'
;import  kernel32,\
;        ExitProcess,'ExitProcess'
import_kernel32
;import  user32,\
;        MessageBox,'MessageBoxW'
import_user32


end     data
    

As far as I can understand, win32wx.inc was designed to use use with .data, .code, .end . Since you use it in your own way - hence the problems Smile
Post 02 Nov 2006, 03:54
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
but what if need to do a parameter-count checking while invoking? i just add 'xp' to basic header do the checking and then erase it back to simplyer one include. and as i remember i did it before.
Post 02 Nov 2006, 06:50
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent
asmfan wrote:
but what if need to do a parameter-count checking while invoking? i just add 'xp' to basic header do the checking and then erase it back to simplyer one include. and as i remember i did it before.

Your original code works with older version of import macro. Since this, it doesn't. Ask Tomasz about his opinion of this problem.
About ebx: (from here)
Iczelion wrote:

When you program under Win32, you must know some important rules. One such rule is that, Windows uses esi, edi, ebp and ebx internally and it doesn't expect the values in those registers to change. So remember this rule first: if you use any of those four registers in your callback function, don't ever forget to restore them before returning control to Windows. A callback function is your own function which is called by Windows. The obvious example is the windows procedure. This doesn't mean that you cannot use those four registers, you can. Just be sure to restore them back before passing control back to Windows.
Post 02 Nov 2006, 08:14
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
Mr_Silent wrote:
Your original code works with older version of import macro. Since this, it doesn't. Ask Tomasz about his opinion of this problem.

Yeah, those changes are still being developed, so you may expect such problems to be gradually resolved. This is a process that I began after a brief discussion with vid about allowing both "A" and "W" functions to be accessed with standard imports (the discussion took place at the 1st fasm's meeting in Kraków), and I decided to introduce those changes in a way that would break backward-compatibility in as few places as possible. As you noticed, it still causes some problems, but I think I will have them fixed soon.
Post 02 Nov 2006, 20:52
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Thx! now i'll sleep well looking forward to see ALLMIGHTY FASM $)
Fasm is great as you are Tomasz!!!
Post 02 Nov 2006, 22:16
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Laughing
Post 02 Nov 2006, 22:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
Please try the updated fasm for Windows package, I've corrected the extended headers to take into account the latest changes in the import packages.
Post 03 Nov 2006, 19:29
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Works nice now, but i still don't understand what for are those strings in extended headers
Code:
include 'api/kernel32.inc'
include 'api/user32.inc'
include 'api/gdi32.inc'
include 'api/advapi32.inc'
include 'api/comctl32.inc'
include 'api/comdlg32.inc'
include 'api/shell32.inc'
include 'api/wsock32.inc'
    

if we have to declare them in import in asm file nevertheless?

_________________
Any offers?
Post 03 Nov 2006, 21:39
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
They get used only if you use the ".end" macro.
Post 03 Nov 2006, 21:54
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
I got it Tomasz, but i don't understand why it is so difficult? While it can be done, IMHO, much easier
Post 04 Nov 2006, 21:16
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
don't know if it can substitute your macro correctly, but could you take a look?
Just to compare them both - original and this one


Description:
Download
Filename: WIN32AX.INC
Filesize: 4.12 KB
Downloaded: 122 Time(s)


_________________
Any offers?
Post 04 Nov 2006, 21:29
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
also not to start new thread there is a different behavior of code below
Code:
tmp1 rb 0
tmp2 db 0 dup (?)
    

the second variant fail to assemble. I faced this problem while doing my custom aligning macro
Post 04 Nov 2006, 23:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
asmfan wrote:
I got it Tomasz, but i don't understand why it is so difficult? While it can be done, IMHO, much easier

This is because the assumption is that it should work even if you include WIN32AX.INC without having those includes in your INCLUDE environment variable (like, by providing the full path, or using %fasminc%, as some of the people still seem to prefer).

[quote="asmfan"]also not to start new thread there is a (...)[/code]
You should have started a new thread - this is a different thing (and this time more appropriate for "Compiler Internals" forum, while current thread I had to move to "Macroinstructions").
Post 05 Nov 2006, 01:30
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.