News:

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

ASM syntax

Started by Seth, December 19, 2005, 03:12:29 AM

Previous topic - Next topic

Seth

Hello everyone I'm new here! I'm working on an assembler and wondering what you guys think about this simple syntax.


\ This is a comment

nextchar:
   lodsb
   cmp al,20h ; je nextchar
   cmp al,09h ; je nextchar


the \ character is used for comments

the ; is used to break lines kind of like 0Dh,0Ah would

I realized using those simple rules my understanding of certain asm code is easier to interpret.

hutch--

Seth,

Generally the trailing backslash is used to denote a split line with things like combined style.

  func arg, STYLE or \
               STYLE2


There is nothing wrong with the idea but it makes it harder for someone coming from another assembler to learn it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Seth

hmm good point.  :U

Yeah I probably should change it to a different character. The problem is finding a character that doesn't look too ugly.  :P

Randall Hyde

Quote from: Seth on December 19, 2005, 04:25:41 AM
hmm good point.  :U

Yeah I probably should change it to a different character. The problem is finding a character that doesn't look too ugly.  :P

The most common comment delimiters are
;   *   #    //

That take you to the end of the current line.
Cheers,
Randy Hyde

zooba

Quote from: Randall Hyde on December 21, 2005, 12:55:25 AM
The most common comment delimiters are
;   *   #    //

Also in the most common list should be these two:

rem '

Okay, the first one is ugly, but I never said anything about beauty  :green2
The second one has been used in BASIC (and its derivations) since people got sick of writing 'rem' all the time  :bg :P

asmrixstar

I reckon you should stick to
  / for continue over next line
  ; for comments

Since most peeps are already used to this (including me :wink)

and maybe
** for a fake CRLF
I really like your idea of including this outside of an invoke command something ive been trying to do in masm for ages
(help there appreciated  :dance:)

Larry Hammick

Quote from: asmrixstar on May 05, 2006, 06:41:06 PMand maybe
** for a fake CRLF
I really like your idea of including this outside of an invoke command something ive been trying to do in masm for ages
(help there appreciated  :dance:)
I like the idea too. RosAsm uses | as a CRLF. For masm I don't know any answer except to write a preprocessor, say "psm2asm.exe", so your build file looks like
...
psm2asm mysource.psm
\masm32\bin\ml /c /coff mysource.asm
...
where psm2asm reads a text source file ("mysource.psm"), replaces "|" with cr+lf, and writes the result to "mysource.asm".

Another idea is to enable several consecutive instructions that have the same mnemonic, e.g.
pop esi edi ebp
but that can be done with macros.

BogdanOntanu

Quote
I like the idea too. RosAsm uses | as a CRLF

Well, for SOL_Asm I was also searching for an character or notation to denote an CR+LF in source at compile time.
I was thinking more  to $cr or $nl or $crlf but I guess "|" could also do but I find it ambiguous...

Besides you rarely need this. For example in Sol_Asm you can write:
mov eax,3   mov ebx,4  push edi   add ecx,1   pop edi   ret
on a single line and you DO NOT need a special character to denote the "end of instruction".

However there are cases when the instruction has an unknown number of expected parameters... like "invoke" without a prototype or a CDECL calling convention or IF you allow this kind of syntax: push eax ebx ecx.

In this case you do not know when it ends, or let us say it ends on CR+LF. This is the situation when having a kind of "soft" CR+LF would be usefully.

"C" programming language made the decission to use ";" as this signal for a soft line end but in ASM we use ";" as a comment and this is well established. Aslo "\" is already used for a line continuation (ie exactly for removing on CR+LF from source at compile time). 

IMHO using ";" for something else is not acceptable in ASM.

So the search for a proper soft CR+LF character or notation is still open but ";" and "\" are both used and have their well established uses in ASM and using them for something completely different will only promote confusion.


Maybe we should gather arround all people that have a "functional" assembler written and people that have huge projects  or big interest in ASM evolution and find a common syntax for ASM. A standard if we may say so...
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Shantanu Gadgil

Quote from: BogdanOntanu on December 14, 2007, 04:27:57 AM
Maybe we should gather arround all people that have a "functional" assembler written and people that have huge projects  or big interest in ASM evolution and find a common syntax for ASM. A standard if we may say so...
That sounds IS a good idea!!!  :toothy

A standard of some sort _might_ actually help !!!

My two cents:
Keep the syntax _not too far off_ from MASM and enhance/update things under which MASM fails.
Maybe, this might help to get many people onboard ?!?

Most appropriate candidates being SolASM and POASM (the ones that I know of)
GoASM with macro (?) support (something which will allow me to write code using .if/.endif, .while/.endw, etc)

Regards,
Shantanu
To ret is human, to jmp divine!

Larry Hammick

Quote from: BogdanOntanu on December 14, 2007, 04:27:57 AMIMHO using ";" for something else is not acceptable in ASM.
I agree. And an assembler could allow the user to choose his own end-of-line character, with a directive such as
eolchar "|"
eolchar 7C  ;hex equivalent
The assembler needs to watch out for the eol character appearing between quotation marks.

Wandering from the topic, IMO any assembler for (say) Intel chips should support the whole big array of mnemonics as they appear in Intel documentation. That is difficult in some spots, because the same mnemonic may refer to different sizes and different kinds of operands. But anybody using the assembler will be working from those Intel manuals. For the ambiguous mnemonics, the operand types need to be specified, either by the declaration of the data or by the syntax of the operands in the instruction, but not by bringing in new mnemonics and requiring the programmer to learn them (which is what RosAsm resorts to, in some places).

One more item from my Santa Claus list: An assembler and linker which really supports the alignment of critical code loops within cache line boundaries.

Vortex

Hi Bogdan,

How is going your SolAsm project?

BogdanOntanu

Quote
Hi Bogdan,

How is going your SolAsm project?

Very well...

OMF and COFF output, listing, alias for API imports, added extra expression operators, structure initializations with field names, can define buffers in LOCAL for PROCs, improved expressions parsing, more 16 bits and 32 bits encodings, fixed a series of bugs, etc

Unfortunately I was also busy with other kind of work and was not able to polish / finish up all this for a new release.

Probably there will be a new release before Christmas or New Year holidays.


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