Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using MASM32 (ML.exe) assembler

779 views
Skip to first unread message

Terence

unread,
Dec 29, 2007, 5:53:16 AM12/29/07
to
I'm fairly competent using MASM for 16 bit work, but when I try to use
ML.exe (my first time) with 32-bit code and assemblere, with this
following (partial) source file, the assembler objects to every
line, then stops after 100 errors on 100 lines.
How should I start the assembly process with the source fle
"myprog.asm" and ask only to assemble and give me an error listing?
When I get that far I MAY have more questions.
The code is all simple "stuff".

c:\MASM32> ML /c myprog.asm .

.486
.model flat, stdcall
;option casemap :none

.code
assume nothing
MyProc proc near
mov ebx,table
;comments
...
(more code, etc)
...

end
Myproc endp

Terence

unread,
Dec 29, 2007, 4:25:48 PM12/29/07
to
I found that the casemap option, causes the include file of
wondows.inc to go crazy, because BOOL and bool are defined as
differenct concepts. So I set casemap to none.
I then experimented without any includes (un-needed anyway) and
changed the target option to 386.

Now my code STARTED to compile to line 54 and then every single line
after that was the same error message.

C:\work>\masm32\bin\ml /c t.asm >myfile

C:MYFILE L00001 C01 Insert
Assembling: t.asm
t.asm(54) : error A2044: invalid character in file
t.asm(55) : error A2044: invalid character in file
t.asm(56) : error A2044: invalid character in file
t.asm(57) : error A2044: invalid character in file
t.asm(58) : error A2044: invalid character in file
t.asm(59) : error A2044: invalid character in file
t.asm(60) : error A2044: invalid character in file
t.asm(61) : error A2044: invalid character in file
t.asm(62) : error A2044: invalid character in file
t.asm(63) : error A2044: invalid character in file
t.asm(64) : error A2044: invalid character in file
t.asm(65) : error A2044: invalid character in file
t.asm(66) : error A2044: invalid character in file
......
t.asm(153) : error A2044: invalid character in file
t.asm(154) : fatal error A1012: error count exceeds 100; stopping
assembly


Line 54 is a comment, followed by simple code as before.
; check the
possibles
shr eax,4 ;shift eax right 4
(55)
mov esi,7 ;init to 7 (56)
mov edi,9 ;9 th on (57)

This is how the program starts.


.386


.model flat, stdcall
option casemap :none

; include \masm32\include\windows.inc ; always first
;
; include \masm32\include\user32.inc ; system include
; include \masm32\include\kernel32.inc ; file next
; include \masm32\include\gdi32.inc
;
; includelib \masm32\lib\user32.lib ; matching system
; includelib \masm32\lib\kernel32.lib ; libraries after that
; includelib \masm32\lib\gdi32.lib
.code

.


MyProc proc near
mov ebx,table
;comments
...
(more code, etc)
...

end
Myproc endp

Why the error stream after line 54?

dave

unread,
Dec 29, 2007, 8:42:34 PM12/29/07
to
Why not use the 'cruntime.inc' from Visual Studio 2005 'C++' compiler
runtime source? There are example routines written in assembler that
provide functions that can't be done with C/C++ at all or efficiently.
Once you have gotten some of those to compile correctly and you have
created a full listing you will know what is required to handle all
three assemblers - x86, AMD64, & IA64. There are a lot of comments in
that file that point out errors in the assembler and the required work
arounds. I thought the 'assume GS:FLAT' statement and its associated
comments was interesting.

There are no manuals or documentation available on the various
assemblers in the Microsoft documentation. I am sure you can find
docs for the IA64 assembler somewhere on Intel's site.

Terence

unread,
Dec 29, 2007, 11:41:26 PM12/29/07
to
I carefully downloaded a different version of ML.exe to a different
directory.
I get the same errors at the same place (line 54 to end of file)
I don't see the problem!.
The only thing I can think of is that these versions run only the
first 50 lines of code or so.
But I have a full CPP license and the new version I used is in the CPP
suite!

dave

unread,
Dec 30, 2007, 12:40:18 AM12/30/07
to
Did you look at the crt runtime files, especially cruntime.inc and how
they are built to create the libraries? MS appears to ship a version
of ml.exe with Visual Studio and the WDK as well. There are also
ml64.exe and ias.exe in the WDK for the two 64-bit environments as
well. That file is very important as it provides some of the answers
I think you are seeking. I haven't done any 32-bit assembly in a very
long time and even then mostly just functions for linking to C
programs.

Bob Masta

unread,
Dec 30, 2007, 8:49:44 AM12/30/07
to
On Sat, 29 Dec 2007 02:53:16 -0800 (PST), Terence
<spam...@crayne.org> wrote:

>I'm fairly competent using MASM for 16 bit work, but when I try to use
>ML.exe (my first time) with 32-bit code and assemblere, with this
>following (partial) source file, the assembler objects to every
>line, then stops after 100 errors on 100 lines.
>How should I start the assembly process with the source fle
>"myprog.asm" and ask only to assemble and give me an error listing?
>When I get that far I MAY have more questions.
>The code is all simple "stuff".

<code snipped>

It's been a while since I downloaded my copy of MASM32,
but it came with tons of examples. I just started with the
examples and worked onward from there. There were also
Iczelion tutorials with their own examples and fairly detailed
explanations.

You may have to root around in your MAS32 directory to
find this stuff.

Best regards,


Bob Masta

DAQARTA v3.50
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, FREE Signal Generator
Science with your sound card!

Terence

unread,
Dec 30, 2007, 10:33:19 PM12/30/07
to
> It's been a while since I downloaded my copy of MASM32,
> but it came with tons of examples.  I just started with the
> examples and worked onward from there.  There were also
> Iczelion tutorials with their own examples and fairly detailed
> explanations.  
>
> You may have to root around in your MAS32 directory to
> find this stuff.
>
> Best regards,
> Bob Masta

Yes, I had looked around and even tried compling some examples; which
worked.
So I think my problem is I don't have included in my code all the
"include" files I thought weren't necessary, since I was only doing
register operations anyway. I'm slowly working through these examples,
very surprised as I progress, at the increasing use of macros and
external tools that these demonstrate; also the weird use of @@: @F:
and @B: dynamic labels, never sspected and guessed as defining,
Forward and Backword jump directions.

I never needed all this stuff as a humble programmer!
But there're VERY interesting frameworks there to build on, including
a pretty complete Windows application with pull-down menues and so on.

So my 30 minute project will end up as an MSc thesis on modern
assembler programming.
:0(> Oh well, I'm not 100 yet...

dave

unread,
Dec 30, 2007, 11:12:32 PM12/30/07
to
@@: is used as a label that can be the target of a jump. Each
successive @@: hides any previous, though a piece of code may have a
@B and a @F at nearby locations (jl @b; je @F; on two lines is my
preference. The jg condition falls through). That has been in MASM
for many years. As the headers in the CRT show there are special
rules about the order certain statements appear. In 16-bit code the
rules are different, so if you have done a lot of that type the 32-bit
code will be a learning experience.

MASM also provides some 'C' like constructs for looping and flow
control. I don't use them since I write assembly when needed and
don't try to make it look like another language. I do use the
anonymous labels and even the externally referenceable labels when
needed. MASM does require blocks though some of the directives can
hide some of the block statements, but a listing with maximum output
specified can show you what was generated.

You can do a branch to a fixed memory location such as the BIOS by
defining a code segment and a target label in that segment. A reboot
in 16-bit boot code can call the reboot address located at the high
end of BIOS segment. There are many things that can be done, but it
takes practice and you have to keep at it since you loose it rather
easily over time.

Greg Falen

unread,
Dec 31, 2007, 6:47:43 AM12/31/07
to
....

> MyProc proc near
> mov ebx,table
> ;comments
> ...
> (more code, etc)
> ...
>
> end
> Myproc endp

The 'end' directive should be the last line - NOT inside the proc!

Tim Roberts

unread,
Dec 31, 2007, 3:04:28 PM12/31/07
to
Terence <spam...@crayne.org> wrote:
>
>I'm fairly competent using MASM for 16 bit work, but when I try to use
>ML.exe (my first time) with 32-bit code and assemblere, with this
>following (partial) source file, the assembler objects to every
>line, then stops after 100 errors on 100 lines.
>How should I start the assembly process with the source fle
>"myprog.asm" and ask only to assemble and give me an error listing?
>When I get that far I MAY have more questions.
>The code is all simple "stuff".

Are you willing to email me the entire source file? I'll see if anything
looks funny, like unexpected control characters.

What version of MASM is it? One of the early MASM 6 releases had a bug
that caused this problem if a line ended exactly on a 4096-byte boundary.

>.code
> assume nothing

You shouldn't use "assume nothing". The .code pseudo-op sets up some
assumes that make the assembly work properly.

>MyProc proc near

"near" and "far" will screw up your 32-bit assembly. Get rid of them.

> mov ebx,table
>;comments
>...
> (more code, etc)
>...
>
> end
>Myproc endp

Those last two are in the wrong order, but I assume that's just a problem
in typing the message.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Terence

unread,
Dec 31, 2007, 11:28:51 PM12/31/07
to
Thanks, guys, but THIS IS INTERESTING.. read on.

1) my ML.exe is V6.14.8444

2) There are some batch files in\mas32\bin, one of which is assmbl.bat
I use th basic part but not all of:-

@echo off
if exist "%1.obj" del "%1.obj"
\masm32\bin\ml /c /coff "%1.asm" > \masm32\bin\asmbl.txt
if errorlevel 0 dir "%1.*" >> \masm32\bin\asmbl.txt
\masm32\thegun.exe \masm32\bin\asmbl.txt

I understand the first lines, but what is program "thegun.exe for",
which uses the output listing?

3) I took the source code that gives me problems (down to T.ASM) and
stuck it in the demo2 tutorial program's main procedure instead of
"hello world".

Then I invoked the assembler using this line.
C:\FORTRAN>\masm32\bin\ml /c /coff t.asm >t.txt

Then I checked t.txt (the result: the assembly listing)

The assembly had gone crazy AS BEFORE, on the SAME LINE (now number
76), which is a comment.
I put the line numbers in brackets afterwords.
I checked the source with a binary dump. There are NO weird characters
or tabs, and all lines end cr-lf.

The very strange thing is I changed code lines, so the source is
different, but the crash is on the SAME COMMENT LINE which hasn't
changed????? (Also by chance the same line number).

test ax,ax ;is zero? (74)
jnz J01A4 ;hop if yes (75)
; check the possibles (76)
shr eax,16 ;shift top down (77)

Assembling: t.asm
t.asm(76) : error A2044: invalid character in file
t.asm(77) : error A2044: invalid character in file
t.asm(78) : error A2044: invalid character in file
t.asm(79) : error A2044: invalid character in file
t.asm(80) : error A2044: invalid character in file
t.asm(81) : error A2044: invalid character in file

And so on till line 176 (again 100 error lines).

So I took out the comment - problem MOVED DOWN to line 86! WHAT????

;loop on bit

SO I TOOK IT OUT!

Problem moved down to somewhere eles !! ON COMMENTS????
;loop on items


FINALLY I GOT IT!

The comments
;check
;loop
;save

and a few others, seem to trigger an error in the assembly, as if it
were a macro or something!

ANY IDEAS WHY????
I'm using a semi-colon than no space before the comment. Is this a NO-
NO?

(Mumble... things used to be simpler..)

Terence

unread,
Jan 1, 2008, 2:35:57 AM1/1/08
to
OK! Solved!

I'm using a text editor which, under certain circumstances, can leave
my comments mangled, including changing a perfectly valid ":" comment
start symbol to the same screen character, but with an 8-bit set and
still showing ";", when it isn't!. One was enough; three were found.
Of course I had searched for tabs and all the usual foul-ups, but when
I realised what was happening and retyped the comments, the problem
went away!

James Van Buskirk

unread,
Jan 1, 2008, 2:25:11 AM1/1/08
to
"Terence" <spam...@crayne.org> wrote in message
news:9518bb55-815e-44c9...@i29g2000prf.googlegroups.com...

> ANY IDEAS WHY????

No, but I've seen such wierd features in assemblers... I was using
one where '7' would generate the byte 37h, 'x' would spit out 78h,
but '#' would not get you anything useful. No errors, no warnings,
no documentation, just garbage code. Or WASM (at least used to)
dislike syntax like mov eax, [4+ecx+2*edx], preferring instead
mov eax, +4[ecx+2*edx]. Again, no errors, no warnings, just garbage
code. At least you are getting errors, and that's easier to debug.
Have you tried asking at the MASM32 forum,
http://www.masm32.com/board/index.php ? The answer may be totally
obvious over there, as you do seem to be using that package.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end

James Harris

unread,
Jan 1, 2008, 7:08:34 PM1/1/08
to

Come back, Notepad. All is forgiven!

Sounds like a nasty editor you have there. Reminds me of olden days
searching for invisible characters in normal-looking text. Yuck.

Terence

unread,
Jan 2, 2008, 4:04:32 AM1/2/08
to
It was Wordstar which fell accidently into document mode while I was
commenting the code.
This puts an extra 8 bit on the first character of a new linw.

All the code was fine; just some text had a hex #BB in position 1 of
the line

;my comment, but that isn't a semicolon on my computer, but ends up as
one in this Forum!

It also shows as semicolon in WS.

This means their is a bug in both ML.exe version 5 and 6, thet, when
meeting this character, CYCLES ON THE SAME LINE complaining about
invalid characters until 100 messages went to stdout.

So you get to find one such error per pass, correct and re-assmble.
Should have proceded to parse further lins of source!

One more question**
How do I code the 32-bit doouble word "move string" operation? This
next is objected to.

movsd repz

Tim Roberts

unread,
Jan 3, 2008, 2:08:26 AM1/3/08
to
Terence <spam...@crayne.org> wrote:
>
>One more question**
>How do I code the 32-bit doouble word "move string" operation? This
>next is objected to.
>
> movsd repz

Other way around. The prefix comes first:
rep movsd
or, if you prefer:
rep movs dword ptr es:[edi], dword ptr ds:[esi]

0 new messages