flat assembler
Message board for the users of flat assembler.

Index > Windows > My Old Macros Dont Work in 1.55 (I think)

Author
Thread Post new topic Reply to topic
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
I upgraded my compiler from 1.51 to 1.55 and now a rather sizeable legacy application won't work (although I got it to compile). I suspect some changes in the standard macro definitions. One of my macros that I use a lot in debugging is provided below.

Code:
; printf call to a message box
; requires a preallocated character array at _t777
; and a title string in _atitle
; this version creates it's own local format string data
; formstr should be an immediate string variable
macro Aprintf  formstr, [args]
{
common
local str00
jmp @f
str00 db formstr,0
@@:
  pusha
  if ~ args eq
   cinvoke wsprintf, _t777, str00, args
  else
   cinvoke wsprintf, _t777, str00
  end if
   invoke MessageBox,  HWND_DESKTOP, _t777, _atitle ,MB_OK
  popa
}

    


This code used to preserve all the registers. I'm not sure if it does anymore. At any rate I suspect the behaviour of this is quite different, since a lot of my procedures now crash shortly after invoking this. Is there anything about the new version of the compiler that would mess this up?

Regards,
-Matt B.

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 23 Sep 2004, 15:13
View user's profile Send private message Visit poster's website Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
Here is a complete, compilable routine


Code:


  ; example of simplified Win32 programming using complex macro features

include '%fasminc%/win32ax.inc'
; printf call to a message box
; requires a preallocated character array at _t777
; and a title string in _atitle
; this version creates it's own local format string data
; formstr should be an immediate string variable
macro Aprintf  formstr, [args]
{
common
local str00
jmp @f
str00 db formstr,0
@@:
  pusha
  if ~ args eq
   cinvoke wsprintf, _t777, str00, args
  else
   cinvoke wsprintf, _t777, str00
  end if
   invoke MessageBox,  HWND_DESKTOP, _t777, _atitle ,MB_OK
  popa
}

.data

_t777 db '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890',0
_atitle db 'Aprintf',0

.code


start:
mov eax, 0
mov ebx, 1
mov ecx, 2
mov edx, 3
Aprintf 'eax: %d  ebx: %d ecx: %d edx: %d', eax, ebx, ecx, edx
Aprintf 'eax: %d  ebx: %d ecx: %d edx: %d', eax, ebx, ecx, edx
invoke  ExitProcess,0

.end start       
    


Sure enough the ebx register has been altered. This did not used to happen before. Here is the description of the pusha instruction from the manual:

pusha saves the contents of the eight general register on the stack. This
instruction has no operands. There are two version of this instruction, one
16–bit and one 32–bit, assembler automatically generates the right version for
current mode, but it can be overridden by using pushaw or pushad mnemonic
to always get the 16–bit or 32–bit version.

What am I missing? Actually I'm also puzzled as to why this compiled. I forgot to load MessageBox from user32.dll

Regards,
-Matt B.

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 23 Sep 2004, 15:35
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
For me it works correctly. How did you perform the update?
Post 23 Sep 2004, 15:57
View user's profile Send private message Visit poster's website Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
To perform the update I simply unpacked the new files into a new directory. However I dumped both the fasmw.exe and fasm.exe files all into the same directory, assuming that there would be no conflict and that they share the same include files etc. After all, what could possibly go wrong? (jk) I forget which one I dumped in there last, but it was probably the fasmc. I set my fasmw.ini to point to the include directory in the install directory (which I called fasm).

Here is another clue. I am providing a dump from Ollydebug for the program above compiled with the two versions. (see enclosure)

The 1.55 versions adds an extra push eax call after the MessageBox call, which it would seem would mess up the stack, and yet 3 out of 4 of my registers are restored and I don't crash.

Should I try a clean install in two separate directories?

OK an update on this. I tried a clean install of fasmw and it worked. Which means that I probably overwrote some stuff with my fasm.exe install into the same directory. One of those installs I downloaded from sourceforge instead of Privalov's download page, which I could not access yesterday. I will now do a seperate install of fasm.exe and see if the problem is still gone.

Yes now they both work, provided I don't try to mix include files. Actually it seems to be ok just to copy the fasm.exe executable over to the fasmw directory.

Thanks for your help.
-Matt


Description: Here are some OllyDebug screen dumps
Download
Filename: macrotestdump.txt
Filesize: 6.64 KB
Downloaded: 111 Time(s)


_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 23 Sep 2004, 16:40
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 GitHub, YouTube, Twitter.

Website powered by rwasa.