News:

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

Dot-NET Support

Started by Twister, June 18, 2011, 08:00:29 AM

Previous topic - Next topic

Twister

I was thinking of making a fun project to do with and for MASM, and well - I thought of adding .NET support. As I was planning on how I was going to write it, I discovered that it would be very difficult and time consuming. The problem that lies here is that MASM also has it's own directives (AND, XOR) and that causes trouble. The assembler is just not up for it. It would work if I made a front-end compiler, and used the assembler as the back-end, but that isn't very a open way.

But ... So far as it is concerned, the MASM assembler is not built for designing new compiling languages with in it using macros.

hutch--

If you want to go the .NET route and feel confident that you could be bothered using it, there is an entirely different "assembler" for .NET than MASM which produces binary files. I did have a play with it once long ago but could not be bothered persisting. You will find that the .NET compilers are supposed to be very good so there may not be any gain in writing your own .NET assembler code.

http://msdn.microsoft.com/en-us/library/496e4ekx(v=vs.71).aspx

MSIL Assembler (Ilasm.exe)
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Twister

hutch,

The route I was intending to create a macro for each opcode in the CIL language. It would just look funny because of how macros are called in MASM (not to mention how difficult it would be)

This is the style to call a macro in MASM, and this is an add opcode from the CIL.
add(val1, val2)

In just plain CIL you would write:
add
( After loading the values first, of course)


I am now thinking that it would just be too much work to put into with no actual benefits.

Twister

It is also not the matter of fact that MASM produces binary files. .NET assemblies and executables are also binaries. They just don't actually have full executable code. The only code that executes is to check to check the assembly, and then feed it into the Common Language Runtime (CLR) and hit play. CorExeMain is the play button (or entry point if you want to get technical :P)

For MASM, it could just be simple macros that fill in data, and use the org directive if it's supported to put data in certain areas.

Here could be a simple nop opcode:
nop MACRO
  db 00
ENDM


It's just that MASM will complain about how it already has its own nop instruction and doesn't want to give it up.  :snooty:

jj2007

Quote from: Horton on June 18, 2011, 08:27:51 AM
It's just that MASM will complain about how it already has its own nop instruction and doesn't want to give it up.  :snooty:

There is a solution for dotnet

include \masm32\include\masm32rt.inc

OPTION DOTNAME

.nop MACRO
nop
ENDM

.code
AppName db "Masm32:", 0

start: .nop
MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start

Twister

Thanks jj. I didn't know that you could put punctuation marks into the macro name.

What is the purpose of OPTION DOTNAME though?

jj2007

Quote from: Horton on June 18, 2011, 06:42:08 PM
Thanks jj. I didn't know that you could put punctuation marks into the macro name.

What is the purpose of OPTION DOTNAME though?

Exactly what it says: it gives you the option to use .names. Which seems kind of natural for a .net project  :green