News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

easm - The Win32 Assembler

Started by Martin_130286, April 13, 2007, 06:36:51 PM

Previous topic - Next topic

Martin_130286

The Epsilon Assembler (easm) is a Win32 assembler whose main focus is Windows application development. I am developing easm as my final year degree project and I wanted to introduce the project to a wider audience and generate some interest.

The assembler is still in very early stages and currently only supports a small percentage of the overall design. In saying this however, easm is capable of creating some interesting things in its current state. My aim is to develop the project, even after it has served the educational purpose that it was created for, to be a fully functional assembler with little to no limits.

I have released a BETA version of easm on the project website (http://e-asm.org) in the hope that people will test the assembler and  report any potential bugs. Bug reporting is particularly important at this stage as I need some evidence that the application has been tested.

Bugs are reported on the project website and require a login to do so (to avoid abuse of the bug reporting system). If you require a login, just complete the short form (found in the 'Bugs' section of the site) and I'll add the login asap. Any feedback would be greatly appreciated and be a huge help.

The website also contains design documents, explanations of relevant concepts, easm source code samples and the online documentation for the easm syntax (http://e-asm.org/Docs)

The easm syntax is essentially x86 assembler, but with a unique touch which aims to make it more manageable and readable, take the following Hello World example:



   subsystem cui

   section imports

        from msvcr70.dll import printf
        from kernel32.dll import ExitProcess

   section constants

        const NULL = 00h

   section data

        string szOutput = "Hello World\n"

   section code

        call printf (&szOutput)
        call ExitProcess (NULL)




easm makes extensive use of Win32 'imports' in order to import functionality from existing code, residing in dynamic link libraries. It is possible to import pretty much any function from any DLL (given its name) and then invoke the function in easm. This produces a huge library of inherited code, much like other languages have access to.

As a final example, the application below was recently created using easm and shows that easm is capable of the development of a fully functional application (even though it is tedious at this point). The program is a simple HTTP downloader, which saves a remote file to a local file given the fully qualified URL.



http://e-asm.org/samples/http.easm
http://e-asm.org/http.exe

Although easm is intended for the Microsoft Windows platform... there has be some success in running the assembler and applications produced by the assembler under Linux systems with the aid of the Windows Emulator WINE. I have not tried this myself, but I am aware that the early examples in easm run fine when using WINE.

Thanks a lot, Martin.

OzzY

Looks good!
Syntax looks clean.
Very HLLish but anyway...
I'll have to do further testing...

Thanks for sharing!

EDIT:
Very nice!
Add support for include files so we don't have to declare every constant.
Cool project! Keep developing it! It has good future!

asmGhost

I've worked with it a little myself.
It has great potential.  :U

Evenbit

Nice!  But you have something wrong with the PE header data.  I got these results running on Windows 98 --

Typing 'arithmatic' at command prompt gave me the DOS stub complaint about needing Win32.

Typing 'start arithmatic' worked... but, of course, that brings up another "command instance" [DOS box] which quickly displays the output and then closes.

OllyDbg complains that the program has an 'entry point' that is outside of the code area.

I am sure their are some seasoned folk around here who can help you sort this out.  Happy coding!

Nathan.

Vortex

That's nice Martin, keep up the good work.

Martin_130286

Thanks for the positive comments everyone, and I'll keep people posted with any significant updates.
Many things are missing but I have every intention of developing these things (structure support, bitwise operators, other output formats....etc)

Quote from: Evenbit on April 15, 2007, 03:52:21 AM
Nice!  But you have something wrong with the PE header data.  I got these results running on Windows 98 --

Typing 'arithmatic' at command prompt gave me the DOS stub complaint about needing Win32.

Typing 'start arithmatic' worked... but, of course, that brings up another "command instance" [DOS box] which quickly displays the output and then closes.

OllyDbg complains that the program has an 'entry point' that is outside of the code area.

I am sure their are some seasoned folk around here who can help you sort this out.  Happy coding!

Nathan.


Thanks for going as far as to try to diagnose this Nathan, I appreciate it.

The reason that OllyDbg complains about the entry point is because easm moves it over any code that is associated with functions, which are encountered before the primary code section. So if there are 2 functions which occupy 20 bytes each, the executable entry point is adjusted by 40 bytes and would typically be 0x00401028 - causing any function's code to be skipped and only executed when a call is made to them.

During my research I noticed that most assemblers tend not to do it this way, having procedures defined later, but I chose to do it this way as it fit in with my overall design better.

I was successful in re-creating the issue you mentioned on a Win98 machine and I can't thank you enough for noticing this - it was a bug :)
The assembler was not setting the correct value in the PE header for the Minor and Major Operating System Version.

I've corrected this now and the stub shouldn't get executed anymore.
I'm going to add your bug report to the website, unless you have any reservations - thanks again.

Regards, Martin.

Evenbit

Quote from: Martin_130286 on April 15, 2007, 05:46:55 PM
I'm going to add your bug report to the website, unless you have any reservations - thanks again.

I have no objections.

Nathan.

Evenbit

Found another one --

I modified "arithmetic.easm" like so:

function void Add (iNum1:2, iNum2:2)

set ax = iNum1
ax += iNum2

end
...
call Add (13w, 5w)
call printf (&szOut, ax)

It gave me error:  Unknown operand used in set command

Nathan.

Martin_130286

As of yet, easm has no direct way (through the set command) of moving a value into ax only.
Contextually, easm knows that the parameter is word-sized and generates:

   movzx eax, word ptr ss:[ebp+offset]

I am aware of this as being a constraint, but it's just one of the many things that still needs completing.

Essentially you'd have to modify the code as so:


section functions

function void Add (iNum1:2, iNum2:2)

set eax = iNum1
eax += iNum2

end

section code

// 13 + 5 == 18
call Add (13d:word, 5d:word)
call printf (&szOut, eax)


lingo

Hi Martin,

I appreciate you efforts in that area  :U
but please help me to answer the question:
"Why to leave MASM compiler and use your?"

Example:
Somewhere my non-friend Vortex stated
Pelle's linker creates smaller exe files and
some people here started using it because of that  :lol

Regards,
Lingo

Evenbit

Quote from: Martin_130286 on April 16, 2007, 07:02:34 AM
As of yet, easm has no direct way (through the set command) of moving a value into ax only.
Contextually, easm knows that the parameter is word-sized and generates:

   movzx eax, word ptr ss:[ebp+offset]

I am aware of this as being a constraint, but it's just one of the many things that still needs completing.

Well, if the set command is passed ax as an operand, it should emmit opcodes for:


   mov ax, word ptr ss:[ebp+offset]


And if passed al then it should emmit:


   mov al, byte ptr ss:[ebp+offset]


For your compiler to be "accepted" as an assembler(tm) it must give the programmer access to all the CPU registers and flags.

Nathan.

Martin_130286

Hi lingo,

In answering your question, easm is not designed to replace MASM at all. In fact, easm is still missing many things which would be considered essential to any complete assembler. If nothing more, easm is for my own learning.

In saying that, I'd ultimately like for easm to support some higher level syntax which may favour windows application development.


Martin_130286

Quote from: Evenbit on April 16, 2007, 10:01:30 PM
For your compiler to be "accepted" as an assembler(tm) it must give the programmer access to all the CPU registers and flags.

Nathan.

Agreed Nathan. This will be resolved in the next build.

Thanks, Martin.

Evenbit

Martin -  is there any progress to report???

I've been playing with it a little.  I have uploaded some examples at http://www.geocities.com/evenbitnb/

bottles.easm -- EASM version of the "99 Bottles of Beer" song.

cinfo.easm -- Example of getting info about the C: drive.

euclid.easm -- Demo of finding GCD using Euclid's algorithm.

gui.easm -- Simplified GUI example.


Nathan.

Martin_130286

Hi Nathan, it's pleasing to see your examples - if only to prove to me others can use easm too :)

As for current progress, I've been dedicating most of my free time over the last few weeks to my final year exams and have had very little time to work on easm.

Now that they're over however, I plan to re-invest some time and work hard towards the next beta release which I ultimately would like to support things mentioned so far, and some other ideas I've been playing around with.

I'll keep everyone updated with any significant updates and work done.

Thanks for taking the time to share these examples, and if you don't mind I'd like to use them when I present easm to my tutors, as a good example of work done by people other than myself.

Thanks Again.

Regards, Martin.