flat assembler
Message board for the users of flat assembler.

Index > Windows > The new macroinstructions for Win32 programming

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Jun 2005, 17:31
you see farrier? That's what i was talking about
Post 27 Jun 2005, 17:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 27 Jun 2005, 20:45
That is a question I was curious about, but it never happened to me because I only use one, and only one, ret per proc. And if I need to exit within the middle of the proc, I jmp to the .dir_out label; which is where I pop what I pushed at the beginning of the proc and returns. I think MASM was more forgiving and popped your pushes, even if you ret from within a proc.

I still think the new proc standard is good, and useful for people coming over from MASM, when used properly. The use of "local"s would seem to avoid any stack related problems, as they become almost like regular varialbles.

A wonderful side benifit I just discovered (Not that it is new); I had a number of utility procs in one file, and when I included this file with the main file, only the procs I actually used in the main file were assembled and included in the exe. This seems like a built in Library Manager to me, that's how I'm going to use it anyway. Is this a good idea?

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 27 Jun 2005, 20:45
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 03 Jul 2005, 09:47
Tomasz Grysztar,

Greetings,

I installed the 27 June 2005 version of FASM 1.62 and while:

Code:
local var[100]:WORD    


works, the following no longer does:

Code:
local var:WORD 100 dup (?)    


Was this a design decision?

Thanks again for the FASM!

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!


Last edited by farrier on 03 Jul 2005, 09:50; edited 1 time in total
Post 03 Jul 2005, 09:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 03 Jul 2005, 09:50
Quote:
Was this a design decision?

Yes.
Post 03 Jul 2005, 09:50
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 03 Jul 2005, 09:53
I understand!

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 03 Jul 2005, 09:53
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 03 Jul 2005, 14:40
Another update to "proc" macro, the "uses" syntax is now enabled:
Code:
proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam    

With MACRO\MASM.INC included, it may look like:
Code:
WindowProc proc uses ebx esi edi, hwnd:DWORD,wmsg:DWORD,wparam:DWORD,lparam:DWORD
  .if [wmsg]=WM_DESTROY
        invoke  PostQuitMessage,0
        xor     eax,eax
  .else
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
  .endif
        ret
WindowProc endp     

I guess I should write some sort of official documentation/manual for the fasmw's macro package.
Post 03 Jul 2005, 14:40
View user's profile Send private message Visit poster's website Reply with quote
mimas



Joined: 21 Jul 2003
Posts: 10
mimas 03 Jul 2005, 16:19
Nice for cleaner and safer code (these registers sometimes forgotten onto stack). As usual, Thanks Tomasz. Smile

What about a wiki for preprocessor/macro documentation? There were tons of change recently, the users contributions may leave you some free time.
Post 03 Jul 2005, 16:19
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 03 Jul 2005, 22:24
Having a problem, I would like to define a directsound interface inside a structure, but doesn't work in the new struct macro. But when I use 'struc', everything works fine. Would it be possible to fix this?
Post 03 Jul 2005, 22:24
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 04 Jul 2005, 11:10
Well, it compiles ok. But when i use it, it crashes. I changed it to a normal struc, and it works fine. I don't know what would make it do this, do you? Here's the example:

Code that doesn't work:
Code:
struct  VOCFILETYPE
        samplerate dd 0
        length     dd 0
        vocbuffer  DirectSoundBuffer
ends    


Code that does work:
Code:
struc  VOCFILETYPE {
       .samplerate dd 0
       .length     dd 0
       .vocbuffer  DirectSoundBuffer
}    
Post 04 Jul 2005, 11:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 04 Jul 2005, 11:20
Oh, you're right, it defines wrong offsets this way. I will try to correct it.
Post 04 Jul 2005, 11:20
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 04 Jul 2005, 11:25
I've uploaded the correction.
Post 04 Jul 2005, 11:25
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 04 Jul 2005, 12:13
All right, works good now. and as always, thanks for your quick response, and fixes Exclamation Very Happy
Post 04 Jul 2005, 12:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 05 Jul 2005, 11:23
mimas wrote:
What about a wiki for preprocessor/macro documentation? There were tons of change recently, the users contributions may leave you some free time.

I think some thread here would be enough. I will start one soon.
Post 05 Jul 2005, 11:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 08 Jul 2005, 09:10
I've improved the locals support, so now it can even declare the initialized locals. For example this:
Code:
locals
 alpha dd 1000
 beta db 100
endl    

will not only allocate the space for locals and define proper labels, but also generate code (at the point in procedure where the declaration is placed) to initialized them.
Of course when you use unitialized values ("?" or reservation directives), only allocation happens.

I consider also adding some stack probing for allocations larger than 1000h bytes, however haven't decided what probing method would be the best. Any advices?
Post 08 Jul 2005, 09:10
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 08 Jul 2005, 14:40
You can use the stack probing from Jørgen "jibz" Ibsen's WCRT, which is based on some code I wrote - I'm sure he won't mind. http://www.ibsensoftware.com .

It's probably a good idea to make the stack probing controllable, it's not always desired...
Post 08 Jul 2005, 14:40
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 08 Jul 2005, 15:04
Yes, I think of it as a kind of some additional setting to the "proc" macro.
Post 08 Jul 2005, 15:04
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 08 Jul 2005, 18:19
And a new feature of extended macros, the "double" prefix for parameters in calling macros, here's the sample program:
Code:
format PE console 4.0

include 'win32ax.inc'

entry $

        stdcall disp,double 3.7
        cinvoke getchar
        invoke  ExitProcess,0

proc disp number:QWORD
        cinvoke printf,"%4.2f",double [number]
        ret
endp

data import

  library kernel32,'kernel32.dll',\
          msvcrt,'msvcrt.dll'

  import kernel32,\
         ExitProcess,'ExitProcess'

  import msvcrt,\
         getchar,'getchar',\
         printf,'printf'

end data    
Post 08 Jul 2005, 18:19
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 11 Jul 2005, 09:05
I've restructured the "proc" macro a bit and made it generate startup/exit code by calling external macros, defined by the "prologue@proc" and "epilogue@proc" symbolic constants. So you can define now alternative prologue/epilogue macros (like stack probing etc.) and just set those constants to get them working with "proc" (the parameters passed to those macro are analoguous to the set of parameters used by MASM for prologue and epilogue macros).

Also the MACRO/MASM.INC emulates the "option" syntax:
Code:
option prologue:none
option epilogue:none    


I only had one design problem with designing those macros, please look at the below two variants. Which in you opinion is better?

The one currently used:
Code:
macro prologuedef procname,flag,parmbytes,localbytes,reglist
 { if parmbytes | localbytes
    push ebp
    mov ebp,esp
    if localbytes
     sub esp,localbytes
    end if
   end if
   if ~ reglist eq
    save@regs reglist
   end if }

macro save@regs [reg] { push reg }    

or alternative:
Code:
macro prologuedef procname,flag,parmbytes,localbytes,[reg]
 { common
    if parmbytes | localbytes
     push ebp
     mov ebp,esp
     if localbytes
      sub esp,localbytes
     end if
    end if
    if ~ reglist eq
   forward
     push reg
   common
    end if }    
Post 11 Jul 2005, 09:05
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 11 Jul 2005, 10:20
Tomasz Grysztar,

Is there an error in the

Quote:
alternative:


In the list of parameters is:

Quote:
[reg]


but in the macro you refer to:

Quote:
reglist


I'm still trying to learn the intricacies of the FASM macro capabilities!

Thanks for your work!!

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 11 Jul 2005, 10:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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.