Author Topic: File input error  (Read 9902 times)

Offline gidak

  • Jr. Member
  • *
  • Posts: 6
File input error
« on: April 25, 2011, 09:55:48 PM »
Hi to all :)
I am programming a program that will be a kind of IDE for programming nasm
my program is in c# and i run the compiler like this
Code: [Select]

   Process p = new Process();
           
            p.StartInfo.Arguments="-f bin hi.asm -o hi.bin";
            p.StartInfo.FileName = @"C:\nasm.exe";
            p.Start();


but when i run it i get a:
Quote
nasm fatal unable to open input file

how can i fix this?
I looked at more threads that had the same problem but I cannot find the answare.
Just to make it clear: The file names are all correct and the paths.

p.s. If theirs a another way to compile nasm code from in a program ill be happy to here

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: File input error
« Reply #1 on: April 25, 2011, 10:00:12 PM »

Code: [Select]
        p.StartInfo.FileName = @"C:\nasm.exe";

Are you sure that you don't really mean:

Code: [Select]
        p.StartInfo.FileName = @"C:\\nasm.exe";

Notice the extra backslash in my example.  Your example contains an escaped newline char '\n'asm.exe
Just a hunch as I'm more of a regular C/C++ guy myself...


Offline gidak

  • Jr. Member
  • *
  • Posts: 6
Re: File input error
« Reply #2 on: April 25, 2011, 10:04:31 PM »
It works ether way And i did try tow slashes (all options 2 back 2 front 1 back 1 front)
plus i dont think the problem is in the path cos it gets to nasm.exe but nasm is making the trouble (I think, probably with help of my code ;) )

edit: Got it working, frgot to add:
Code: [Select]
p.startinfo.workingdirectory=@"c:\\";man how im stupid ;)
« Last Edit: April 25, 2011, 10:30:58 PM by gidak »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: File input error
« Reply #3 on: April 25, 2011, 11:28:52 PM »
(No, "stupid" people don't do asm at all! :) )

You mention "another way"... I've done something similar - in asm, for Linux, using "sys_exec" to run Nasm from within my program. I don't think it'll be any use to you, but I'll post it if you want...

Best,
Frank


Offline gidak

  • Jr. Member
  • *
  • Posts: 6
Re: File input error
« Reply #4 on: April 26, 2011, 12:41:50 AM »
Ill be happy if you post it :)
nothing like getting more input to my brain XD
edit: BTW is their a archive of old nasm source code? (Not code demos)
« Last Edit: April 26, 2011, 12:47:42 AM by gidak »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: File input error
« Reply #5 on: April 26, 2011, 03:35:58 AM »
Okay. This is "even worse than I remembered". I thought I had a "low level" or "raw" version - can't find it now. This uses macros... from .inc files that have been modified from their original form. It'll be even less use to you than I thought!

What I though might be relevant to the problem you were having (but apparently isn't) is the way arguments (and environment) are passed to sys_execve. I need an array of pointers to strings (both zero-terminated). The first arg needs to be the name of the program (argc is always at least 1), the rest of 'em are what we pretend was on the command line...

Code: [Select]
section .data

; the argument strings
    editor db '/usr/bin/mcedit', 0   ; vi, emacs, e3, ...
    ed_in db 'hello.asm', 0

; the array to pass to sys_execve
    ed_args dd editor, ed_in, 0

    assembler db '/usr/local/bin/nasm', 0  ; Fasm, HLA, Gas, ...
    outform db '-felf', 0
    optim db '-O999', 0
    dbg db '-g', 0
    objname db '-ohello.o', 0
    inname db 'hello.asm', 0

    asm_args dd assembler, outform, optim, dbg, objname, inname, 0
   
    linker db '/usr/bin/ld', 0
    lnk_s db '-s', 0
    lnk_in db 'hello.o', 0
    lnk_out db '-ohello', 0

    lnk_args dd linker, lnk_s, lnk_out, lnk_in, 0

I thought you might need something like that to pass arguments, but apparently C# is different (duh!).

As you can see, everything's hard-coded in. The "interface" consists of putting the code you want to assemble in the directory with this program - named "hello.asm" (whatever it is). I was mostly just trying to run another program from my program... and get back! sys_execve doesn't "return", it just exits, so I had to sys_fork first, and sys_wait for the child to return. It was my first experience with sys_fork, and it took me a while to sort out "being in two places at once"! I think I got it, but I didn't get any farther with it...

If the .tar.bz2 is a problem (I think 7zip will do it) I can provide other formats, but I really don't think it "applies" to what you're doing.

Are you looking for an archive "of" Nasm code - the code to Nasm itself? Yeah http://www.nasm.us has got it going way back. If you're looking for code to assemble with Nasm... not much but "demos". Jeff Owen wrote a lot of stuff for Linux - all in Nasm - including an IDE (or two). He's abandoned it. I thought it was on SourceForge, but I can't find it now. I've got it, anyway. A bit too large to post the whole package here. Best documentation of sys_calls I've ever seen, among other things. Really ought to be archived! Maybe I'll break it down into postable chunks...

Best,
Frank


Offline gidak

  • Jr. Member
  • *
  • Posts: 6
Re: File input error
« Reply #6 on: April 26, 2011, 04:38:00 AM »
Thank you very much for all the help and support you gave me.
I hope to publish my program on the forums soon :)
Its not something very good cos i need to run the debugger as a external program but a nice source code editor
with options to make bin com exe and write boot-loaders to floppy's.

If you have any more ideas please tell me. ;)