Using c++ to call TASM to assemble .asm into .com

Hi,
I am new to c++, could anyone point me to how can I write a c++ code which will call TASM to assemble the .asm file into a .com and execute it?

I've written a c++ code that compiles into .asm file but could not see any online resouce on how to invoke TASM to assemble the generated .asm file.

Thanks!
I am not sure what you are asking, so I will answer a couple of possible questions this could be.

-- if your c++ compiler is set to generate assembly, that is just for YOU to look at. Many programmers look at this to see if the generated assembly is doing something poor and will rewrite to get speed by checking the output if they see an issue. You do not generally assemble these files. Instead, you should compile the c++ to an executable program directly.

-- if you are writing assembly with your code as part of what your code DOES, you can invoke the assembler yourself. The system() command is a crude way, and there are advanced versions with spawn family, windows has its own family, shellexecute family, and so on. The simply run the program for you from your own program.

-- if you are trying to assemble the output of the compiler yourself as an assembly program, it should work like one you wrote yourself, but it may need to tap libraries that you need to provide a path for. This is not something I have had to do since school when they walked us through the process, and a LOT has changed since then... you may need to google up a set of instructions.
Last edited on
Why do you need a .COM file? What are you trying to do?
okay, so intuitively, I'll just have to code it in the same way as I would have executed TASM in the command prompt? That also means I will have to invoke "cd.." first, to locate where tasm.exe is? I'll let you guys know of the result once I get hold of my machine..
Can I buy a vowel?
Last edited on
@tpb, I've written a compiler from scratch, which translates a .cpp file into .asm, now, I am looking for a way to inject a code into my c++ source that will invoke TASM to assemble the generated .asm file and turn it into a .com file.. hope that makes more sense..
I meant in your name.

I doubt you write a C++ compiler from scratch if you can't figure out how to run TASM.

And you never answered helios's question. Why do you need a .com file?
no, you don't need cd.

the cheesy system version: (the dos command is the same no matter what flavor you pick, its the other options that vary)

system("c:\\someplace\\moredeep\\tasm.exe somefile.asm -o -p -q -xyz"); //whatever tasm needs, I have not seen tasm since the 90s..


-- all a com file is, is .exe with a different name and a specific memory model (which, are memory models even still USED??). All this stuff is a blur from long ago... are you writing for a 386? Or do they still do stuff this way?

Last edited on
thanks jonnin! and it outputs 8086 assembly, I plan to run it on dosbox or emu8086, the reason why ".com" is that what was specified by the the teacher..
oh, ok. I have some dim memories of all that, but its been a long, long while. I ran my 386 until win98 came out and supported it for a few years after that (gave it to my grandpa who had discovered email). I was po and couldn't afford an upgrade in college (or after, for a short time), and win95 vanilla was actually slower and worse than a good dos box anyway.

I can try to help a little bit but as I said, that stuff is a very, very distant memory now. If the memory model is correct, from what I recall, you can just rename an exe to com or you can have the tool use that name, either one. It really shouldnt matter for school work, but do what the teacher says I guess.

Even a simple, partial c++ compiler is a lot of work. Good stuff.
Last edited on
thanks jonnin! and yes, .exe and .com are interchangeable.. funny, most people are prolly thinking I was building a full blown c++ compiler, the compiler I did just supports cin, cout, if/else, comments, basic computations.. the deadline was in two days so I was really desperate for a quick answer.. Nonetheless, you guys have been a big help :) thanks everyone
Topic archived. No new replies allowed.