Sol_Asm: A new Assembler emerging

Started by BogdanOntanu, October 07, 2007, 12:43:20 AM

Previous topic - Next topic

BogdanOntanu

Hi all,

Here it is a new Solar Assembler release.

http://www.oby.ro/sol_asm/files/sol_asm_2007_10_07_bin.zip

The package contains:
- the Solar Assembler binary: sol_asm2.exe
- a brief documentation in file: read_me.txt
- 2 simple win32 samples in .\samples folder
- license agreement in file: LICENSE.TXT

For your reference, you can also see the brief description on-line here:
http://www.oby.ro/sol_asm/files/read_me.txt


Solar Assembler has evolved a lot since I have restarted it's development 3 months ago.

I've waited with this release until I was able to compile Solar_OS with SOL_ASM. This is a huge step forward since Solar_Os is a huge application and exposed many bugs in SOL_ASM.

Besides this way we have obtained our precious Independence Day for SOLAR OS ;)

I am serious about this product and I intend to make it of industry standard strength.

So please feel free to:
- criticize, test, bug report
- suggest improvement ideas
- request features you consider useful in an professional assembler

Here are a few features of special interest for MASM users:
- Invoke without PROTO
- Invoke with variables and symbols defined after it
- Invoke does parameter checking for Procedures defined later on in file(s)

It will have INVOKE and PROC and all of the HLL goodies in 64bits encoding mode.
The same thing will be functional for Win32, Win64, Solar_OS and Unix OS.

There will be plug-ins for cross compiling other architectures and OSes and user added features.
The development is accelerated, you can expect multiple releases in the next months.

You have the opportunity to request, debate and influence Solar Assembler syntax and features because it is not yet fully established.

Do not forget that this release is still tagged as "Alpha" so there are many miss features and bugs.
From my point of view this is the first "alpha" of Solar Assembler.

But it is also the the very first version that is practically usable and has proven itself at least against 2 very big applications.



Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

six_L

 :U :U :U
congratulate the great step.
regards

ramguru

I can do "typecast" with tbyte but there is no "dt" keyword mentioned in the list, strange. Not sure about the meaning of 'section "code"    class_code' is this invented just to give user ability to choose whatever goes after the dot: '.code' '.biglazycode' '.c' .etc ? Confused regarding 'my_ps PAINTSTRUCT 0,1' do this substitute 'dup' and how to refer to second structure, oh yeah I haven't also noticed 'sizeof' in the keyword list, is this how I do it: invoke BeginPaint,[wnd_handle], my_ps+64 ? And here the last question go: what about resource compiler? I see no resource section (beginning with class_ ... )

BogdanOntanu

Quote from: ramguru on October 07, 2007, 08:45:48 AM
I can do "typecast" with tbyte but there is no "dt" keyword mentioned in the list, strange.

You are right, thanks for pointing this out. Adding "dt" and "rt" now... as we speak ;)
I had a need for "tbyte" casting on some FPU code in Solar_OS but forgot to add "dt" and "rt".

And since we are at it... What would be the preferred syntax for 128 bits data type: "dh" or "do" ?

Quote
Not sure about the meaning of 'section "code"    class_code' is this invented just to give user ability to choose whatever goes after the dot: '.code' '.biglazycode' '.c' .etc ?

"class_code" is just an easy way to say: readable executable initialized
"class_data" is just another way to say: readable writeable initalized

Of course that the detailed section flags will be added but for a start I have considered some simple commonly used section types.

And yes the user has the ability to choose section name and automatically what comes after "dot operator" in .data .code section selection. Hence, if defined, '.biglazycode' or".c" are perfectly valid section names. BTW you can have multiple similar sections for code or data etc.


Quote
Confused regarding 'my_ps PAINTSTRUCT 0,1' do this substitute 'dup' and how to refer to second structure,

In practice this syntax is not yet fixed but as it is now in that example there should be 2 (two) PAINTSTRUCT structures defined. First structure should be filled with 0 and the seccond one with 1. You can address them in the same way you address multiple data items declared on the same line or label.

If you intend to reserve data for 1024 of structures or as a substitute for "dup" you should use the "rs" keyword (reserve structure).

Quote
oh yeah I haven't also noticed 'sizeof' in the keyword list,

It is there, forgot to mention it. It is named SIZE.

This is valid:

mov eax, SIZE PAINTSTRUCT


I will tell you a secret ;)

SIZE is defined but "pro forma" only.
In fact the name of a structure does represent it's size in certain operations.

Hence you can simply write:

mov eax, PAINTSTRUCT
or
add esi, PAINTSTRUCT


Quote
is this how I do it: invoke BeginPaint,[wnd_handle], my_ps+64 ?

You can write something like that...

You can also do:


mov esi,my_ps
add esi, SIZE PAINTSTRUCT
...
invoke BeginPaint,[wnd_handle],esi
...


or

invoke BeginPaint,[wnd_handle],my_ps+<size PAINTSTRUCT>,...


And I guess I could also add this:

invoke BeginPaint,[wnd_handle],my_ps[N],...


Quote
And here the last question go: what about resource compiler? I see no resource section (beginning with class_ ... )

I will add a resource type for sections and later on a resource compiler.

If you have a better name or syntax for "class_ ..." I am open to suggestions.


Thanks you for questions, tips, criticism and comments...
keep them comming no matter if positive or negative since they do nevertheless provide hints for improvements.

After all this is just an alpha release ;)

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Vortex

Congratulations Bogdan, very nice work :U

BogdanOntanu

Thanks Vortex and six_L for your kind words...

I hope to finish 64 bits encoding and win64 output long before ML64 is completly disabled and we all avoid having to write hand macro's for INVOKE, .IF and stuff like that ;)
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

ramguru

Thanks for thorough explanation.

Quote from: BogdanOntanu on October 07, 2007, 09:41:50 AM
And since we are at it... What would be the preferred syntax for 128 bits data type: "dh" or "do" ?
Let's see it's 128 bits, so it's 16 bytes, so it's 8 words, we may say it's Octuple Word I guess 'do' would be OK.

Quote from: BogdanOntanu on October 07, 2007, 09:41:50 AM
If you have a better name or syntax for "class_ ..." I am open to suggestions.
I don't know, for me class referes to OOP maybe sec_ would make more sense.

Quote from: BogdanOntanu on October 07, 2007, 09:41:50 AM
It is there, forgot to mention it. It is named SIZE.
Thanks for letting me know that.

Quote from: BogdanOntanu on October 07, 2007, 09:41:50 AM

invoke BeginPaint,[wnd_handle],my_ps[N],...

I'm sure this syntax would be appreciated by many people, I find it a little too high level though.

Quote from: BogdanOntanu on October 07, 2007, 09:41:50 AM
Thanks you for questions, tips, criticism and comments...

So far there were questions & comments, criticism coming soon after I try it in one of my project (sorry I'm kinda busy these days, learning vhdl, verilog, systemC all that stuff.. since I mentioned verilog, your number representation 888_99_00 seems to be borrowed from that language :)

Vortex

Hi Bogdan,

Trying to add the equate MessageBox equ  <MessageBoxA> to your example code, I received an error message :

;------------------------------------------------------
; Sol_Asm assembler core
; Copyright (c) 2004-2007, Bogdan Valentin Ontanu.
; All rights reserved.
;------------------------------------------------------

;------------------------------------------------------------------
; This file is used to test Sol_ASM
; win32_pe format generation
;------------------------------------------------------------------

import_dll kernel32.dll
import_func ExitProcess
import_func GetStdHandle

import_dll user32.dll
import_func MessageBoxA
MessageBox equ  <MessageBoxA>


section "code" class_code
section "idata" class_imports
section "data"  class_data

STD_INPUT_HANDLE EQU -10
STD_OUTPUT_HANDLE EQU -11


.data

sz_message db "First Win32 PE application",0
sz_title db "Sol_ASM",0


.code

;invoke GetStdHandle, STD_INPUT_HANDLE

invoke MessageBox, 0, sz_message, sz_title, 3

Call ExitProcess

ret

nop
nop


Assembling file: test_win32.asm
Assembler  pass: 1
**Error** test_win32.asm(18) EQU, expresion not defined? MessageBoxA


I get the same message when I add the equate following the definition of STD_OUTPUT_HANDLE Is there something that I miss?

BogdanOntanu

Hi Vortex,

Yes, I forgot to mention that currently EQU result value can only be a number NOT a literal string.

TXTEQU is planed for a future release.

But I see your point here: many times text equates are used to define API names that have ASCII and UNICODE versions. And later on in code you can use a single API name for both UNICODE or ASCII versions of your application.

Maybe I can find a way to improve the import_func syntax a little an this way we could avoid typing a lot of such TXTEQU's

One way I could see it done as it is now would be to used #ifdef like this:



UNICODE EQU 1

#ifdef UNICODE
import_func Function_nameW
#else
import_func Function_nameA
#endif

or

MACRO MessageBox
MARG hwnd, lptext, lpcaption, utype

invoke MessageBoxA,hwnd,lptext,lpcaption,utype

ENDM



But I do agree it would be kind of complicated. This issue was noted ... Thanks for pointing it out to me
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Vortex

Hi Bogdan,

Thanks for the message. I asked about the equates because I am intending to create include files ( defining API functions ) for SolAsm.

BogdanOntanu

Quote from: Vortex on October 07, 2007, 08:16:57 PM
Hi Bogdan,

Thanks for the message. I asked about the equates because I am intending to create include files ( defining API functions ) for SolAsm.

Oh, That would be outstanding! having include files for a new assembler is always a problem. Thank you.

Besides that fact that TXTEQU or friends will be implemented I was thinking of a quick fix for this API name issue.

What if I redefine import_func syntax like this:

...
import_func MesageBoxA as MessageBox
...


Adding the "as" keyword to give an user name for an API name.

This way the parser could know both symbols at compile time or only the last "as" or "alias" one

Is that any better... ?


Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

BogdanOntanu

Oh dear,

One thought that crossed my mind when thinking about this API name issue was:


from user32.dll  import MessageBoxA as MessageBox


I confess ...
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Vortex

Hi Bogdan,

import_func MesageBoxA as MessageBox

and

from user32.dll  import MessageBoxA as MessageBox

are both nice ideas.

I can modify my dll2inc tool to create the include files for Sol_Asm. Using my tool def2lib, I can create all the necessary MS COFF import libraries with decorated and \ or  non-decorated symbols. The big work is to create the master window.inc file containing all the structure definitions and equates.

Mark Jones

Quote from: Vortex on October 08, 2007, 04:37:47 PM
...The big work is to create the master window.inc file containing all the structure definitions and equates.

I am working on something like this now, except using a database. However we must check the SDK license to verify this is allowable. I needed drive space so deleted my SDK for the moment, and don't have near enough free space for the latest version. It would be a great help if someone could look into that.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Vortex

Hi Mark,

Japheth created a nice set of include files. It's Public Domain :

QuoteWin32Inc is a set of include files for MASM or POASM created by h2incx. It contains all includes required to build Win32 applications or dlls. If you also have got PellesC (see the links page where to get it), there's everything available to create Win32-PE binaries in Assembler. Be aware that Win32Inc is intended for people being familiar with the command line interface and experienced in programming (not necessarily Assembler, however). There is also no installer supplied, just a compressed package of directories and files together with a simple README.TXT trying to explain things.

http://www.japheth.de/win32inc.html