flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Heap > FASM1+FASMG AllInOne package

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
FASM1+FASMG AllInOne package
1st post updated. attachment updated. again(21.08.17).
First of all this package is instrument for windows targeted to crossplatform development, not being crossplatform itself.
Package presented as well organized mix of oficial fasm1 & fasmg packages: to avoid possible confusion all fasmg relative folders has _G postfix still fasm1 folders hasn`t it.
Fasmw adaptated for compilation source files in both syntaxes fasm1 & fasmg.
Fasm console removed atall (removed exe, not sources).
Package is path independent and it well operate on paths with cirilic or whitespaces in them.
Fasmg compilation here is configured wia automation scripts, throw that scripts is realized additional handling: in main source file at fasmg syntax can be placed directives for that scripts for naming output file (directive ";rename binary as") or for doing some postcompile actions(directive ";launch CMD line") (simplest of them is running output executable or opening output data in coresponding viewer). In very limited cases this scripts can`t do some conditional postcompile actions so they must be realized in old way throw unique cmd or bat for particular source.
At current state automation scripts and connected with them compilation cases has 3 variants:
1. convinient for continous editing & testing code - no messages if source compilable, and message with error if source has error
2. same as 1st, but all output files going to same output folder
3. convinient for exploring macro behavior - messages of compilation goes to txt file that is displayed instead of displaying standart CMD window
Includes made crossbit (same structures for 64 & 32) anywhere where it was possible.

format.inc (for fasmg) in package extended to handle push pop sequences without commas.
listing.inc (for fasmg) in package updated according to last version of it and looks compatibable with all sources(and examples) in fasmg relative folders.
no more (from 21.08.2017 struct.inc is backuped): struct.inc (for fasmg) in package updated according to last version of it - so it proper reflect with PE.relocation.
new: storing of relocated datas resolved in formatter macros, no needed to duplicate it in struct.inc.

For better understanding fasmg polynomes in package added fasmg example describing polinomes behavior.

ATENTION:Sources of fasm1 in package uncompatibable with oficial package in resource section: fasm1 source texts in package have dialog macros that expect one more parameter than in oficial fasm1, each dialogitem can have additional data that cannot migrate to old fasm1, and for flagset fields in dialogs is possible to combine them only with "or" not "+". And DS_SETFONT style now not hardcoded in dialog - to make sources looks like in oficial fasm1 this flag should be added directly.
Improvement resource macros (for now only ones for RT_DIALOG modernized) moved from macros in examples to include sections of both fasm1 & fasmg. All test with RT_DIALOG done & success.
Moreover (from 21.08.17) in menues added incompatibility too: in fasm1 menu gain one more parameter than in fasm oficial release & menu ended with end menu(or endmenu), against oficial fasm1 release here supported both menu & menuex.
All test with RT_MENU done & success.

libc.fasmg source updated according update in oficial fasmg.
In project added version log (previously was only version log for separate fasm1 & fasmg in, for fasmg version log added fossil link instead of txt file)

Started support of kolibry: added source for kolibri version of fasm1. Maked hotfix i missed previously 3 last zeroed dwords of load_libraries_struct.
Also added example of conditional including realized in fasm1 version.

Started support of macOS (according to official release): added source for macOS version of fasmg.

litle changes of fasmw menu interface.


Description:
Download
Filename: FASM (1 & G)ALLinONE.zip
Filesize: 1.64 MB
Downloaded: 4 Time(s)

Description:
Download
Filename: THIS PACKAGE.TXT
Filesize: 3.93 KB
Downloaded: 4 Time(s)


_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 21 Aug 2017, 09:36; edited 24 times in total
Post 02 Jun 2017, 11:43
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland
Re: Is It possible to redisign fasmg package?

ProMiNick wrote:
The main idea is separating includes from examples.
Separate both of them by opcodeset, than by OS, than by bits (x86|x64).

These includes were meant as an examples themselves - in this case examples how a complex instruction sets like x86 can be implemented. I planned to have actual sets of macros for specific purposes as a separate releases.


Last edited by Tomasz Grysztar on 02 Jun 2017, 12:40; edited 1 time in total
Post 02 Jun 2017, 12:00
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
It would be great if all development will be within single package by all OS, all opcode sets, all bits (like it in fresh but more common). I think separate releases is evil - their macros incompatibable (without modifications) via cross release.

And at current time development of new (some of them) fasmg macros going out of context - it is bad too.
Post 02 Jun 2017, 12:25
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland
On a few occations I suggested a creation of some central collaboration hub/repository for fasmg macro projects, but it did not gain much traction. I cannot do it without more people, all I can manage is to slowly work on my basic examples and auxiliary documentation.

But looking at the failure of similar collaboration project for fasm 1 I do not have much faith in such idea. So all we have is a bunch of separate projects.
Post 02 Jun 2017, 12:40
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
out of topic:
I don`t understand behavior of macro named with dot inside, actualy behavior of locals in it


Code:
macro x86.parse_operand ns,op
        ns.size = 0
        match prefix valueop
                match :szx86.prefix ; Match defines only "prefix", so where from "x86.prefix"? It is some kind of concatenation early defined symbol "x86" and matched param "prefix"? Or local got prefix "x86" because macro has that "x86" prefix.
                        ns.size = sz
                        x86.parse_operand_value ns,value
                else
                        x86.parse_operand_value ns,op
                end match
        else
                x86.parse_operand_value ns,op
        end match
end macro



Why others then x86 codeset realized not in same manner (same is throw element of register type and so on)? because of simplicity of their codesets? or for another reason?

return to topic:
however, I interest in that linux examples were included in fasmg examples as windows included, or at least macros for linux (fasmg macros & linux - is 2 of my weak place, I can't do it myself with writing macros at the junction of the 2 unknowns).
Post 02 Jun 2017, 13:39
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland
[quote="ProMiNick"]out of topic:
I don`t understand behavior of macro named with dot inside, actualy behavior of locals in it

Code:
                match :szx86.prefix ; Match defines only "prefix", so where from "x86.prefix"? It is some kind of concatenation early defined symbol "x86" and matched param "prefix"? Or local got prefix "x86" because macro has that "x86" prefix.

When "prefix" is (during macro preprocessing) replaced with a value like "dword", second parameter to MATCH becomes "x86.dword" and then, since there is a symbolic constant with such name defined, it is replaced with the symbolic value of "x86.dword", namely ":4". This then matches the ":sz" pattern and "sz" parameter gets value "4".


ProMiNick wrote:
Why others then x86 codeset realized not in same manner (same is throw element of register type and so on)? because of simplicity of their codesets? or for another reason?

Registers could be recognized in a similar manner (compare the Z80-based samples in my introduction to fasmg) but for x86 I prefer to have a linear algebra on registers (like it was in fasm 1) so the ELEMENT was the only option for implementing them. In fact the ELEMENT directive was designed exactly to simulate how fasm 1 handled things like register algebra and addresses with relocatable base.


ProMiNick wrote:
however, I interest in that linux examples were included in fasmg examples as windows included, or at least macros for linux (fasmg macros & linux - is 2 of my weak place, I can't do it myself with writing macros at the junction of the 2 unknowns).

If you include "format.inc" that comes with fasmg, you can assemble many of the simple examples from fasm 1 without changes. Try with ELFEXE or ELFOBJ. You can even assemble the original source written for fasm 1 with a command like:

Code:
fasmg -iInclude('format/format.inc'hello.asm hello

Post 02 Jun 2017, 16:33
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
out of topic:
so, summarize:
1. macro called "x86.parse_operand", where "x86" in name dosn`t matter nothing special.and macro can be called with any other set of symbols.
2. as second parameter match get "x86.prefix" where we have 3 independent symbols "x86", ".", "prefix", but not global "x86" with its descendant "prefix"

and new questions:
"x86" previously defined as blank, what for?
why "x86" is not changed to blank in 2nd parameter of match, like "prefix" is changed to forex. "dword". Or that changing is happen? But same changing is happened in "x86.dword" declaration, witch becomes ".dword" declaration.

return to topic:
in package that i attach to this topic i include simple linux examples and they are worked. but examples that marked as dynamic that i named hello2 - they dont work. i know because of my mistake of porting fasm macros to fasmg macros.
Post 02 Jun 2017, 18:18
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland

ProMiNick wrote:
"x86" previously defined as blank, what for?

It does not really matter what value it has, but it need to be defined as global symbol to ensure that every reference to "x86.something" accesses the same namespace. If there was no "x86" globally defined, the use of such symbol inside some descendant namespace would refer to local "x86" instead.


ProMiNick wrote:
why "x86" is not changed to blank in 2nd parameter of match, like "prefix" is changed to forex. "dword". Or that changing is happen?

The "prefix" is a macro parameter, it is replaced during the preprocessing of line, before the line goes to actual assembly. After that replacement line contains identifier "x86.dword" and it is as a whole an identifier of a symbol. The "x86" would be evaluated with its (empty) value only if it was used as a standalone identifier.

You can look at it this way: identifiers of symbols may contain dots (and question marks in the right places) while names of parameters (macro parameters, but also ones defined by directives like MATCH or ITERATE) may not, as they are replacements of elementary name tokens. Also parameters are replaced earlier, before the instruction is recognized.


ProMiNick wrote:
in package that i attach to this topic i include simple linux examples and they are worked. but examples that marked as dynamic that i named hello2 - they dont work. i know because of my mistake of porting fasm macros to fasmg macros.

The Linux version of fasmg uses the ported dynamic import macros. You can find them in "source/linux/selfhost.inc".
Post 02 Jun 2017, 19:25
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
For out of topic answers - all is clear now. Thanks.


Quote:
The Linux version of fasmg uses the ported dynamic import macros. You can find them in "source/linux/import32.inc".


In package of fasmg that I have this macros has fasm syntax not fasmg (i.e. macro with curved brackets). I look for if in last release of fasmg with same macro but in fasmg syntax. maybe i missed release.
Post 02 Jun 2017, 20:00
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland

ProMiNick wrote:

Quote:
The Linux version of fasmg uses the ported dynamic import macros. You can find them in "source/linux/import32.inc".


In package of fasmg that I have this macros has fasm syntax not fasmg (i.e. macro with curved brackets). I look for if in last release of fasmg with same macro but in fasmg syntax. maybe i missed release.

I edited my post to correct my mistake but you have read it faster. Wink
Note that all the version of fasmg can be self-hosted, and it's been this way for more than a year.
Post 02 Jun 2017, 20:27
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
Post removed: error log of previos package version (Bugs in BATfiles)


Last edited by ProMiNick on 19 Jul 2017, 13:59; edited 1 time in total
Post 02 Jun 2017, 23:09
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
Post removed: in WinXP wasn`t supported relative paths as expected (BATfiles corrections)


Last edited by ProMiNick on 19 Jul 2017, 14:02; edited 1 time in total
Post 02 Jun 2017, 23:56
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
Tomasz i meet a problem:

macro format in format.inc expects opode extending just inside of it:

Code:
macro format? clause 
match =MZ?clause
                include 'x86/cpu/p6.inc'
                include 'x86/opcodeextender.inc' ; its vacant place
                include 'x86/format/ms/dos/mz.inc'
...
                end while
                include 'x86/format/ms/win/pe.inc'
                include 'x86/cpu/p6.inc'
                include 'x86/opcodeextender.inc' ; its vacant place
                use32 
...
and so on...




is it possible to define opcode extender outside of macro format?

For example opcode extender of push,pop - how change it so its definition stayed outside of macro format (without changing macro format itself, that changing I described above):

Code:
;# content of file opcodeextender.inc
iterate instrpush,pop
        macro instr? op
                local sequence
                sequence equ op --
                while 1
                        match --, sequence
                                break
                        else match carcdrsequence
                                redefine sequence cdr
                                match :szx86.car
                                        match --, sequence
                                                instr car
                                                break
                                        else match headtailsequence
                                                redefine sequence tail
                                                instr car head
                                        end match
                                else
                                        instr car
                                end match
                        end match
                end while
        end macro
end iterate




and what decision is preferable? Adding strokes of "include 'x86/opcodeextender.inc'" to each format clause
or defining macros for opcode extending outside of format.inc?

Target is escape from short form of macro format in selfhost.inc to common macro format and replace selfhost atall by standart includes. So examples and sources uses the same includes. And yes, my target also is to support opcode extending in most usable way.
Post 07 Jun 2017, 08:01
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland

ProMiNick wrote:
is it possible to define opcode extender outside of macro format?

You can simply include additional extensions after the macro, as the "win64avx" example demonstrates:

Code:
include 'format/format.inc'

format PE64 NX GUI 5.0
entry start

include 'avx.inc'

But not that the "format" macro is only there to emulate some compatibility with fasm 1 and it does use the full capabilities of the new macros. For better control it is better to use them directly or write a better wrapper (probably not fasm 1 compatible anymore).
Post 07 Jun 2017, 10:13
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
Post removed: it was temporary: all valuable content of this post added to 1st post. all other now outdated and goes nowhere.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 15 Jun 2017, 14:48
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
1st Question is connected with error that opcodeextender.inc creates.
Tomasz, as I think sequented push|pop shoul be for regs only? how it is in fasm1?only general regs? If so, I should add condition "if ... metadata metadata =x86.reg"


And 2nd question: still I changed fasmw role from pure fasmg editor and added fasm content, and now each fasm release I have to inject same changes to same places of updated source.

For sources less than 64kb I can use BATfiles, fasmw greater so needed utility. It is not very needed: slightly outdated fasm enought for usual purposes, critical updates not so frequent, and patches count not so big.

However, utility for patching sources (inserting templates or patches in them) may be useful.
Post 19 Jul 2017, 15:01
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6441
Location: Kraków, Poland

ProMiNick wrote:
1st Question is connected with error that opcodeextender.inc creates.
Tomasz, as I think sequented push|pop shoul be for regs only? how it is in fasm1?only general regs? If so, I should add condition "if ... metadata metadata =x86.reg"

In fasm 1 this worked with any arguments, and it was a source of many problems.
Post 19 Jul 2017, 15:16
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
updates for standart dialog resource (however it still applicable for new syntax of rsrc section)
fasmg

Code:
macro dialog class,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize
   if style and 0FFFF0000h = 0FFFF0000h
     .err dialog version mismatch
   end if
   dd style,exstyle+0
   dw items,x,y,cx,cy
   ;test menu indicator
   if menu+0 = 0
     dw 0
   else if menu eqtype ''
     du menu,0
   else
     dw 0FFFFh,menu
   end if
   ;test class indicator
   if class+0 = 0
     dw 0
   else if class eqtype ''
     du class
   else
     dw 0FFFFh,class
   end if
   ;test title indicator
   match any,title
     du title ;,0 from common case below
   end match
              dw 0

   if style and DS_SETFONT
     match any,fontname
       du fontsize+0,fontname,0
     else
       du 8,'MS Sans Serif',0 ; fasm1 legacy
     end match
   end if
   align 4
   dialog_items_counter = 0
end macro



fasm1

Code:
macro dialog label,class,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize
 { local data,size,items
   label dd RVA data,size,0,0
   data dd style+0,exstyle+0
   dw items,x,y,cx,cy
   menudone = 0
   match ,menu \{ dw 0
   menudone = 1\}
   match  any =, more,menu \{ du menu,0
   menudone = 1\}
   if menudone
   else if menu eqtype ''
     if menu eq ''
       dw 0
     else
       du menu,0
     end if
   else
     if ~menu
       dw 0
     else
       dw 0FFFFh,menu
     end if
   end if
   classdone = 0
   match ,class \{ dw 0
   classdone = 1\}
   match  any =, more,class \{ du class,0
   classdone = 1\}
   if classdone
   else if class eqtype ''
     if class eq ''
       dw 0
     else
       du class,0
     end if
   else
     if ~class
       dw 0
     else
       dw 0FFFFh,class
     end if
   end if
   titledone = 0
   match ,title \{ titledone = 1\}
   match  any =, more,title \{ du title
   titledone = 1\}
   if ~titledone & title eqtype ''
     if ~title eq ''
       du title ;,0 from common case below
     end if
   end if
              dw 0
   if style and DS_SETFONT
     if fontname eq
       du 8,'MS Sans Serif',0
     else
       du fontsize+0,fontname,0
     end if
   end if
   align 4
   dialog_size equ size = $ - data
   dialog_items equ items = dialog_items_counter
   dialog_items_counter = 0 }



equates for extended dialogs:

Code:
ANSl_CHARSET       = 0
DEFAULT_CHARSET     = 1
SYMBOL_CHARSET      = 2
MAC_CHARSET         = 77
SHIFTJIS_CHARSET    = 128
HANGEUL_CHARSET     = 129
HANGUL_CHARSET      = 129
JOHAB_CHARSET       = 130
GB2312_CHARSET      = 134
CHINESEBIG5_CHARSET = 136
GREEK_CHARSEÒ       = 161
TURKISH_CHARSET     = 162
VIETNAMESE_CHARSET  = 163
HEBREW_CHARSET      = 177
ARABIC_CHARSET      = 178
BALTIC_CHARSET      = 186
THAI_CHARSET        = 222
EASTEUROPE_CHARSET  = 238
RUSSIAN_CHARSET     = 204
OEM_CHARSET         = 255



extended dialog resource
fasmg

Code:
macro dialogex label,class,title,x,y,cx,cy,style,exstyle,menu,helpID,fontname,fontsize,fontweight,italic,charset:1
   align 16
   dw 1,0FFFFh
   dd helpID+0
   dd exstyle+0,style+0
   dw items,x,y,cx,cy
   if menu+0 = 0
     dw 0
   else if menu eqtype ''
     du menu,0
   else
     dw 0FFFFh,menu
   end if
   if class+0 = 0
     dw 0
   else if class eqtype ''
     du class
   else
     dw 0FFFFh,class
   end if
   match any,title
     du title ;,0 from common case below
   end match
              dw 0
   ;fontweight=0..1000; 0=default=400; bold = 700
   if style and (DS_SETFONT or DS_SHELLFONT)
     match any,fontname
       dw fontsize+0,fontweight+0
       db italic+0,charset
       du fontname,0
     else
       dw 8,400
       db italic+0,charset
       du 'MS Sans Serif',0
     end match
   end if
   align 4
   dialog_items_counter = 0
end macro



extended dialog resource
fasm1

Code:
macro dialogex label,class,title,x,y,cx,cy,style,exstyle,menu,helpID,fontname,fontsize,fontweight,italic,charset
 { local data,size,items
   label dd RVA data,size,0,0
   align 16
   data dw 1,0FFFFh
   dd helpID+0
   dd exstyle+0,style+0
   dw items,x,y,cx,cy
   menudone = 0
   match ,menu \{ dw 0
   menudone = 1\}
   match  any =, more,menu \{ du menu,0
   menudone = 1\}
   if menudone
   else if menu eqtype ''
     if menu eq ''
       dw 0
     else
       du menu,0
     end if
   else
     if ~menu
       dw 0
     else
       dw 0FFFFh,menu
     end if
   end if
   classdone = 0
   match ,class \{ dw 0
   classdone = 1\}
   match  any =, more,class \{ du class,0
   classdone = 1\}
   if classdone
   else if class eqtype ''
     if class eq ''
       dw 0
     else
       du class,0
     end if
   else
     if ~class
       dw 0
     else
       dw 0FFFFh,class
     end if
   end if
   titledone = 0
   match ,title \{ titledone = 1\}
   match  any =, more,title \{ du title
   titledone = 1\}
   if ~titledone & title eqtype ''
     if ~title eq ''
       du title ;,0 from common case below
     end if
   end if
              dw 0
   ;fontweight=0..1000; 0=default=400; bold = 700
   if style and (DS_SETFONT or DS_SHELLFONT)
     if fontname eq
       dw 8,400
       db italic+0
       if charset eq
         db 1
       else
         db charset
       end if
       du 'MS Sans Serif',0
     else
       dw fontsize+0,fontweight+0
       db italic+0
       if charset eq
         db 1
       else
         db charset
       end if
       du fontname,0
     end if
   end if
   align 4
   dialog_size equ size = $ - data
   dialog_items equ items = dialog_items_counter
   dialog_items_counter = 0 }


_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 13 Aug 2017, 19:15; edited 5 times in total
Post 26 Jul 2017, 12:29
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
standart dialogitem
fasmg:

Code:
macro dialogitem class,titleorID,id,x,y,cx,cy,style,exstyle
   align 4
   dd style or WS_CHILD,exstyle+0
   dw x,y,cx,cy,id
   match ,class
     dw 0
   else if class eqtype ''
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else
       du class
     end if
   else
     if (class and 1Fh) =10 | (class and 1Fh) =10h | (class-(class and 80h))>18h | class<0
       .err unsupported classID = class
     end if
     dw 0FFFFh,class
   end if
   if titleorID+0 = 0 ; no title no subitems
     dw 0
   else if titleorID eqtype '' ;title
     du titleorID,0
   else
     assert class = 10
     dw 0FFFFh,titleorID ; subitem: ID of ICO,BMP ... etc.
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1
end macro



extended dialogitem
fasmg:

Code:
macro dialogitemex class,titleorID,id,x,y,cx,cy,style,exstyle,helpID
   align 4
   dd helpID+0,exstyle+0,style or WS_CHILD
   dw x,y,cx,cy
   dd id ; for dialogitemex ID is word sign-extended to dword, however upper part can be any but most of window messages operate under lo word part only
   match ,class
     dw 0
   else if class eqtype ''
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else
       du class
     end if
   else
     if (class and 1Fh) =10 | (class and 1Fh) =16 | (class-(class and 80h))>18h | class<0
       .err unsupported classID = class
     end if
     dw 0FFFFh,class
   end if
   if titleorID+0 = 0 ; no title no subitems
     dw 0
   else if titleorID eqtype '' ;title
     du titleorID,0
   else
     dw 0FFFFh,titleorID ; subitem: ID of ICO,BMP ... etc.
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1
end macro



createwindowstruct of dialogitem or dialogitemex
fasmg

Code:
macro dialogitemextra
   local fin
   store fin-$:word at $-2 

   macro end?.dialogitemextra
     fin = $
   end macro
end macro



standart dialogitem
fasm1:

Code:
macro dialogitem class,title,id,x,y,cx,cy,style,exstyle
 { align 4
   dd style or WS_CHILD,exstyle +0
   dw x,y,cx,cy,id
   if class eq
     dw 0
   else if class eqtype ''
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else if class eq ''
       dw 0
     else
       du class,0
     end if
   else
     if (class and 1Fh) =10 | (class and 1Fh) =16 | (class-(class and 80h))>18h | class<0
       .err unsupported classID = class 
     end if 
     dw 0FFFFh,class
   end if
   titledone = 0
   match ,title \{ dw 0
   titledone = 1\}
   match  any =, more,title \{ du title,0
   titledone = 1\}
   if titledone
   else if title eqtype ''
     if title eq ''
       dw 0
     else
       du title,0
     end if
   else
     if ~title
       dw 0
     else
       dw 0FFFFh,title
     end if
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1 }



extended dialogitem
fasm1:

Code:
macro dialogitemex class,title,id,x,y,cx,cy,style,exstyle,helpID
 { align 4
   dd helpID+0,exstyle +0,style or WS_CHILD
   dw x,y,cx,cy
   dd id ; for dialogitemex ID is word sign-extended to dword, however upper part can be any but most of window messages operate under lo word part only
  if class eq
     dw 0
   else if class eqtype ''
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else if class eq ''
       dw 0
     else
       du class,0
     end if
   else
     if (class and 1Fh) =10 | (class and 1Fh) =16 | (class-(class and 80h))>18h | class<0
       .err unsupported classID = class 
     end if 
     dw 0FFFFh,class
   end if
   titledone = 0
   match ,title \{ dw 0
   titledone = 1\}
   match  any =, more,title \{ du title,0
   titledone = 1\}
   if titledone
   else if title eqtype ''
     if title eq ''
       dw 0
     else
       du title,0
     end if
   else
     if ~title
       dw 0
     else
       dw 0FFFFh,title
     end if
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1 }



createwindowstruct of dialogitem or dialogitemex
fasm1 (that was never was earlier in fasm1):

Code:
macro dlgitmxtrdata
 { local fin
   store word (fin-$at $-2
   macro enddlgitmxtrdata \{ fin = $ \} }



Any critics and suggestions are appreciated


Last edited by ProMiNick on 13 Aug 2017, 19:20; edited 5 times in total
Post 26 Jul 2017, 14:05
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 80
Location: Russian Federation, Sochi
in above macros there is no syntactic errors: both and fasm1 and fasmg compiled successfuly.

but
AniWindow example from fasmg:

Code:
format PE GUI 4.0 ;rename binary as 'ANIBLEND.EXE'
entry start       ;launch CMD line '%OUTPUT%'

AW_HOR_POSITIVE     = 1h
AW_HOR_NEGATIVE     = 2h
AW_VER_POSITIVE     = 4h
AW_VER_NEGATIVE     = 8h
AW_CENTER       = 10h
AW_HIDE         = 10000h
AW_ACTIVATE     = 20000h
AW_SLIDE        = 40000h
AW_BLEND        = 80000h

include 'ABI\WIN\win32a.inc'

section '.text' code readable executable

  start:

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,dlgname,HWND_DESKTOP,DialogProc,0;dlgname,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,eax

proc DialogProc hwnd,wmsg,wparam,lparam
        mov     eax,[wmsg]
        cmp     eax,WM_INITDIALOG
        je      .wminitdialog
        cmp     eax,WM_COMMAND
        je      .wmcommand
        cmp     eax,WM_CLOSE
        je      .wmclose
        jmp     .finish
  .wminitdialog:
        invoke  AnimateWindow,[hwnd],500,AW_ACTIVATE or AW_BLEND
        invoke  SetFocus,[hwnd]
        jmp     .finish
  .wmcommand:
  .wmclose:
        invoke  AnimateWindow,[hwnd],500,AW_HIDE or AW_BLEND
        invoke  EndDialog,[hwnd],0
  .finish:
        xor     eax,eax
        ret
endp

section '.data' data readable writeable

  dlgname TCHAR 'MAINSCREEN',0
  hInstance dd ?

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  include 'ABI\WIN\API\KERNEL32.INC'
  include 'ABI\WIN\API\USER32.INC'

macro dialog class,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize
   if style and 0FFFF0000h = 0FFFF0000h
     .err dialog version mismatch
   end if
   dd style,exstyle+0
   dw items,x,y,cx,cy
   if menu+0 = 0
     dw 0
   else if menu eqtype ''
     du menu,0
   else
     dw 0FFFFh,menu
   end if
   if class+0 = 0
     dw 0
   else if class eqtype ''
     du class
   else
     dw 0FFFFh,class
   end if
   match any,title
     du title ;,0 from common case below
   end match
              dw 0

   if style and DS_SETFONT
     match any,fontname
       du fontsize+0,fontname,0
     else
       du 8,'MS Sans Serif',0
     end match
   end if
   align 4
   dialog_items_counter = 0
end macro

ANSl_CHARSET       = 0
DEFAULT_CHARSET     = 1
SYMBOL_CHARSET      = 2
MAC_CHARSET         = 77
SHIFTJIS_CHARSET    = 128
HANGEUL_CHARSET     = 129
HANGUL_CHARSET      = 129
JOHAB_CHARSET       = 130
GB2312_CHARSET      = 134
CHINESEBIG5_CHARSET = 136
GREEK_CHARSEÒ       = 161
TURKISH_CHARSET     = 162
VIETNAMESE_CHARSET  = 163
HEBREW_CHARSET      = 177
ARABIC_CHARSET      = 178
BALTIC_CHARSET      = 186
THAI_CHARSET        = 222
EASTEUROPE_CHARSET  = 238
RUSSIAN_CHARSET     = 204
OEM_CHARSET         = 255

macro dialogex class,title,x,y,cx,cy,style,exstyle,menu,helpID,fontname,fontsize,fontweight,italic,charset:1
   dw 1,0FFFFh
   dd helpID+0,exstyle+0,style+0
   dw items,x,y,cx,cy
   if menu+0 = 0
     dw 0
   else if menu eqtype ''
     du menu,0
   else
     dw 0FFFFh,menu
   end if
   if class+0 = 0
     dw 0
   else if class eqtype ''
     du class
   else
     dw 0FFFFh,class
   end if
   match any,title
     du title ;,0 from common case below
   end match
              dw 0
   ;fontweight=0..1000; 0=default=400; bold = 700
   if style and (DS_SETFONT or DS_SHELLFONT)
     match any,fontname
       dw fontsize+0,fontweight+0
       db italic+0,charset
       du fontname,0
     else
       dw 8,400
       db italic+0,charset
       du 'MS Sans Serif',0
     end match
   end if
   align 4
   dialog_items_counter = 0
end macro

macro dialogitem class,titleorID,id,x,y,cx,cy,style,exstyle
   align 4
   dd style or WS_CHILD,exstyle+0
   dw x,y,cx,cy,id
;needed testing
   if class+0 = 0
     dw 0
   else if class eqtype ''
;legacy part - no needed testing
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else
       du class
     end if
;end legacy - needed testing
   else
     dw 0FFFFh,class
   end if
;end class cases
   if titleorID+0 = 0 ; no title no subitems
     dw 0
   else if titleorID eqtype '' ;title
     du titleorID,0
   else
     dw 0FFFFh,titleorID ; subitem: ID of ICO,BMP ... etc.
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1
end macro

macro dialogitemex class,titleorID,id,x,y,cx,cy,style,exstyle,helpID
   align 4
   dd helpID+0,exstyle+0,style or WS_CHILD
   dw x,y,cx,cy,id
   ;align 4 or dw 0 - maybe here or maybe not - not tested
;needed testing
   if class+0 = 0
     dw 0
   else if class eqtype ''
;legacy part - no needed testing
     if class eq 'BUTTON'
       dw 0FFFFh,80h
     else if class eq 'EDIT'
       dw 0FFFFh,81h
     else if class eq 'STATIC'
       dw 0FFFFh,82h
     else if class eq 'LISTBOX'
       dw 0FFFFh,83h
     else if class eq 'SCROLLBAR'
       dw 0FFFFh,84h
     else if class eq 'COMBOBOX'
       dw 0FFFFh,85h
     else
       du class
     end if
;end legacy - needed testing
   else
     dw 0FFFFh,class
   end if
;end class cases
   if titleorID+0 = 0 ; no title no subitems
     dw 0
   else if titleorID eqtype '' ;title
     du titleorID,0
   else
     dw 0FFFFh,titleorID ; subitem: ID of ICO,BMP ... etc.
   end if
   dw 0
   dialog_items_counter = dialog_items_counter + 1
end macro

macro dlgitmxtrdata
   local fin
   store fin-$:word at $-2

   macro end?.dlgitmxtrdata
     fin = $
   end macro
end macro

macro end?.dialog?
  items = dialog_items_counter
end macro


section '.rsrc' resource data readable

  resource_directory

    virtual at 0
                du 'MAINSCREEN'
                load dlg_name:$ from 0
        end virtual

    resource_data RT_DIALOG,dlg_name,LANG_ENGLISH+SUBLANG_DEFAULT
      dialog ,'Using Windows AnimateWindow API',29,28,307,84,DS_CENTER or WS_VISIBLE or WS_CAPTION or WS_SYSMENU
        dialogitem 'BUTTON',' Uses a fade effect animation when dialog is created ',-1,7,7,294,33,WS_VISIBLE+BS_GROUPBOX+BS_CENTER+BS_FLAT
        dlgitmxtrdata
          dd 0,3457375
        end dlgitmxtrdata
        dialogitem 'STATIC','invoke AnimateWindow, [hwnd], 500, AW_ACTIVATE or AW_BLEND',-1,14,16,280,18,WS_VISIBLE+SS_CENTERIMAGE
        dialogitem 'BUTTON',' Uses a fade effect animation when dialog is closed ',-1,7,43,294,33,WS_VISIBLE+BS_GROUPBOX+BS_CENTER+BS_FLAT
        dialogitem 'STATIC','invoke AnimateWindow, [hwnd], 500, AW_HIDE or AW_BLEND',-1,14,53,280,18,WS_VISIBLE+SS_CENTERIMAGE
      end dialog
    end resource_data
  end resource_directory



and AniWindow from fasm1 examples(with fix: in dialog inserted 2nd param class):

Code:

; Simple text editor - fasm example program

format PE GUI 4.0
entry start

AW_HOR_POSITIVE     = 1h
AW_HOR_NEGATIVE     = 2h
AW_VER_POSITIVE     = 4h
AW_VER_NEGATIVE     = 8h
AW_CENTER       = 10h
AW_HIDE         = 10000h
AW_ACTIVATE     = 20000h
AW_SLIDE        = 40000h
AW_BLEND        = 80000h

include 'win32ax.inc'

section '.text' code readable executable

  start:

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0;dlgname,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,eax

proc DialogProc hwnd,wmsg,wparam,lparam
        mov     eax,[wmsg]
        cmp     eax,WM_INITDIALOG
        je      .wminitdialog
        cmp     eax,WM_COMMAND
        je      .wmcommand
        cmp     eax,WM_CLOSE
        je      .wmclose
        jmp     .finish
  .wminitdialog:
        invoke  AnimateWindow,[hwnd],500,AW_ACTIVATE or AW_BLEND
        invoke  SetFocus,[hwnd]
        jmp     .finish
  .wmcommand:
  .wmclose:
        invoke  AnimateWindow,[hwnd],500,AW_HIDE or AW_BLEND
        invoke  EndDialog,[hwnd],0
  .finish:
        xor     eax,eax
        ret
endp

section '.data' data readable writeable

  dlgname TCHAR 'MAINSCREEN',0
  hInstance dd ?

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  include 'API/KERNEL32.INC'
  include 'API/USER32.INC'

section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs

  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration

  dialog demonstration,,'Using Windows AnimateWindow API',29,28,307,84,DS_CENTER or WS_VISIBLE or WS_CAPTION or WS_SYSMENU
    dialogitem 'BUTTON',' Uses a fade effect animation when dialog is created ',-1,7,7,294,33,WS_VISIBLE+BS_GROUPBOX+BS_CENTER+BS_FLAT
    dlgitmxtrdata
          dd 0,3457375
        enddlgitmxtrdata
    dialogitem 'STATIC','invoke AnimateWindow, [hwnd], 500, AW_ACTIVATE or AW_BLEND',-1,14,16,280,18,WS_VISIBLE+SS_CENTERIMAGE
    dialogitem 'BUTTON',' Uses a fade effect animation when dialog is closed ',-1,7,43,294,33,WS_VISIBLE+BS_GROUPBOX+BS_CENTER+BS_FLAT
    dialogitem 'STATIC','invoke AnimateWindow, [hwnd], 500, AW_HIDE or AW_BLEND',-1,14,53,280,18,WS_VISIBLE+SS_CENTERIMAGE
  enddialog


compiled application executed successfuly

still
Dialog example from fasm1 (with fix: in dialog inserted 2nd param class):

Code:

include 'win32a.inc'

ID_CAPTION         = 101
ID_MESSAGE         = 102
ID_ICONERROR       = 201
ID_ICONINFORMATION = 202
ID_ICONQUESTION    = 203
ID_ICONWARNING     = 204
ID_TOPMOST         = 301

section '.text' code readable executable

  start:

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
        or      eax,eax
        jz      exit
        invoke  MessageBox,HWND_DESKTOP,message,caption,[flags]
  exit:
        invoke  ExitProcess,0

proc DialogProc hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      .wminitdialog
        cmp     [msg],WM_COMMAND
        je      .wmcommand
        cmp     [msg],WM_CLOSE
        je      .wmclose
        xor     eax,eax
        jmp     .finish
  .wminitdialog:
        invoke  CheckRadioButton,[hwnddlg],ID_ICONERROR,ID_ICONWARNING,ID_ICONINFORMATION
        jmp     .processed
  .wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + IDCANCEL
        je      .wmclose
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        jne     .processed
        invoke  GetDlgItemText,[hwnddlg],ID_CAPTION,caption,40h
        invoke  GetDlgItemText,[hwnddlg],ID_MESSAGE,message,100h
        mov     [flags],MB_OK
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONERROR
        cmp     eax,BST_CHECKED
        jne     .iconerror_ok
        or      [flags],MB_ICONERROR
      .iconerror_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONINFORMATION
        cmp     eax,BST_CHECKED
        jne     .iconinformation_ok
        or      [flags],MB_ICONINFORMATION
      .iconinformation_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONQUESTION
        cmp     eax,BST_CHECKED
        jne     .iconquestion_ok
        or      [flags],MB_ICONQUESTION
      .iconquestion_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONWARNING
        cmp     eax,BST_CHECKED
        jne     .iconwarning_ok
        or      [flags],MB_ICONWARNING
      .iconwarning_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_TOPMOST
        cmp     eax,BST_CHECKED
        jne     .topmost_ok
        or      [flags],MB_TOPMOST
      .topmost_ok:
        invoke  EndDialog,[hwnddlg],1
        jmp     .processed
  .wmclose:
        invoke  EndDialog,[hwnddlg],0
  .processed:
        mov     eax,1
  .finish:
        pop     edi esi ebx
        ret
endp

section '.bss' readable writeable

  flags dd ?
  caption rb 40h
  message rb 100h

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         CheckRadioButton,'CheckRadioButton',\
         GetDlgItemText,'GetDlgItemTextA',\
         IsDlgButtonChecked,'IsDlgButtonChecked',\
         MessageBox,'MessageBoxA',\
         EndDialog,'EndDialog'

section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs

  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration

  dialog demonstration,,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
    dialogitem 'STATIC','&Caption:',-1,10,10,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_CAPTION,10,20,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
    dialogitem 'STATIC','&Message:',-1,10,40,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_MESSAGE,10,50,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
    dialogitem 'BUTTON','&Icon',-1,10,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Error',ID_ICONERROR,20,82,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON+WS_TABSTOP+WS_GROUP
    dialogitem 'BUTTON','I&nformation',ID_ICONINFORMATION,20,95,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Question',ID_ICONQUESTION,20,108,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Warning',ID_ICONWARNING,20,121,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Style',-1,100,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Top most',ID_TOPMOST,110,82,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX
    dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
    dialogitem 'BUTTON','C&ancel',IDCANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
  enddialog


execution is fault with error "unknown software exception 00000005"

solution found: instead of pluses use or in style definition

Code:
dialog demonstration,,'Create message box',70,70,190,175,WS_CAPTION or WS_POPUP or WS_SYSMENU or DS_MODALFRAME; or DS_SETFONT



new problem IDE Fasmw source became uncompilable again:

Code:
error value out of range
if~'flat assembler ',2014h,' version ','1.71.64',0Dh,0Ah,'Copyright ',0A9h,' 1999-2017 Tomasz Grysztar.'


I even didn`t expect to operate such strings: <'flat assembler ',2014h,' version ',VERSION_STRING,0Dh,0Ah,'Copyright ',0A9h,' 1999-2017 Tomasz Grysztar.'>

solution found maybe not most optimal but workable:
replace

Code:
if title eq
     dw 0


with

Code:
titledone = 0
   match ,title \{ dw 0
   titledone = 1\}
   match  any =, more,title \{ du title,0
   titledone = 1\}
   if titledone


inl macro dialogitem & dialogitemex

I hope no one would try to make complex values <,> to dialog.fontname or dialogitem.class in all rest parts of macros they are ready to handle that.
Post 26 Jul 2017, 19:41
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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 can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.