News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Masm failing when called from c++

Started by armedturret, February 23, 2018, 10:21:36 AM

Previous topic - Next topic

armedturret

I am (attempting) to write a compiler for BASIC. I can successfully generate assembly code that compiles if I manually type in the command from the console but fails if I call it from c++ with create process.
This is my compiler output:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\Users\rjwhi\Desktop\compilerexamples\Basic\tmp\tmp.asm
C:\Users\rjwhi\Desktop\compilerexamples\Basic\tmp\tmp.asm(1) : error A2088: END directive required at end of file

What's even more strange, is when I had it output the command generated, it worked fine but in a directory above the target.
Here is the command:
C:\masm32\bin\ml.exe /c /Zd /coff /I"C:\masm32\Include" "C:\Users\rjwhi\Desktop\compilerexamples\Basic\tmp\tmp.asm"
I would like to note I am just testing if it can assemble first before I link it.
The generated assembly code is as follows
.386
.model flat, stdcall
option casemap :none
include windows.inc
include kernel32.inc
include masm32.inc
includelib kernel32.lib
includelib masm32.lib
.data
PrintStr0 db "Hello world!",0
PrintStr1 db "OOF",0
PrintStr2 db "OOF",0
.code
start:
invoke StdOut, addr PrintStr0
invoke StdOut, addr PrintStr1
invoke ExitProcess, 0
end start

jj2007

Quote from: armedturret on February 23, 2018, 10:21:36 AM
I am (attempting) to write a compiler for BASIC.

Welcome to the club ;)

Quotetmp.asm(1) : error A2088: END directive required at end of file

The assembler complains that, in line 1, it expected END and didn't find it. Which simply means that tmp.asm is an empty file! So check what the heck the IDE is producing at that point. The easiest thing is to temporarily replace ML.exe (or UAsm64.exe?) with a fake ML.exe that just produces a messagebox. While that box is showing, check if tmp.asm exists, and what's inside.

LordAdef


Hi Armedturret, in this regard I can tell you Jochen is THE guy to help!

aw27

It will compile fine if you escape the double quotes and the escapes themselves (if you define the command line inside the C++, otherwise no need).

"h:\\masm32\\bin\\_ml.exe /c /Zd /coff /I\"h:\\masm32\\Include\" tmp.asm"

_ml is my 21 years old masm (unfortunately it is not not whisky).

armedturret

Quote from: jj2007 on February 23, 2018, 05:02:34 PM
Quotetmp.asm(1) : error A2088: END directive required at end of file

The assembler complains that, in line 1, it expected END and didn't find it. Which simply means that tmp.asm is an empty file! So check what the heck the IDE is producing at that point. The easiest thing is to temporarily replace ML.exe (or UAsm64.exe?) with a fake ML.exe that just produces a messagebox. While that box is showing, check if tmp.asm exists, and what's inside.
Welp, turns out I forgot to close the write stream and the file was empty.

aw27

Pity, we love to blame Masm for everything that goes wrong.