Author Topic: unable to open file  (Read 22624 times)

nobody

  • Guest
unable to open file
« on: December 30, 2005, 07:06:59 AM »
im running windows xp and i just want to get a simple program to enter dos and exit. Only problem is nasm cant seem open the asm file even though its in the same directory as its in.
Here is the error message:

nasm: fatal: unable to open input file 'test.asm'

And here is the source if its anything to do with the stuff in there.

section .data
prompt      db   "Enter a number: ", 0

section .text
main:
int 20

I have tried this with other asm files too and they all give the same error.Any help would be greatly appreciated.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: unable to open file
« Reply #1 on: December 30, 2005, 09:12:28 AM »
Dunno. Never seen this, when the file actually exists. What I *have* seen is goddamWindows editors saving your file as "test.asm.txt", or some name you didn't ask for. Could that be it?

Best,
Frank

nobody

  • Guest
Re: unable to open file
« Reply #2 on: December 30, 2005, 02:39:41 PM »
hey Frank,

thanks for the reply. The problem was that i didn't add the full path to it.So its nasmw -f coff test.asm. The only thing now i would really like to do is make an exe. I have Dev-C++, which I have tried to use gcc to link my object file, but I dont think thats what i need. I also use programmers notepad now. :)

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: unable to open file
« Reply #3 on: December 30, 2005, 04:30:40 PM »
Okay... I'm not familiar with Dev-C++ - I assume it uses Mingw/Cygwin gcc - targeting a PE file. If that's correct, you want "-f win32", not "-f coff" (that's for djgpp's variant of COFF - although they're quite similar). Also, you'd want to call "ExitProcess", not int 20h.

If what you want is dos, the easiest thing is to use "-f bin" to output a file directly to .com format. You'll want to use "-o myfile.com" (otherwise Nasm defaults to just "myfile"... which could be renamed...). You'd also want to put "org 100h" at the top of your source - although what you show would work without it. (when you try to print the "prompt", you'd need it - and if you're thinking of using int 21h/9 - end it with '$'!!!)

If you wanted a 16-bit dos .exe (an "MZ" executable format), use "-f obj" and link it with Alink, or Val, or an old MS 16-bit linker. The linker with Dev-C++ (named "ld", I imagine) *might* work for that, but I doubt it. You'd want a "stack" segment and an entrypoint ("..start"), to go that route.

Personally, I think starting out with dos .com files is easiest, although "learning dos" is not very useful, in itself, these days. With WinXP, it'll be "fake" (emulated) dos, but it works *almost* like "real" dos. :)

If you want to get into 32-bit programming, I don't think it covers Dev-C++(?), but Dr. Carter's tut might help:

http://www.drpaulcarter.com/pcasm

Best,
Frank