running the assembler

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

running the assembler

bader
as i have read:
The Hack assembler reads as input a text file named Prog.asm, containing a Hack
assembly program, and produces as output a text file named Prog.hack, containing the translated Hack machine code. The name of the input file is supplied to the
assembler as a command line argument:
prompt> Assembler Prog.asm
--------------------------------------------------------------------------
if i understood correctly, when running the program we supply the name of the file
as a command line argument, and we do not supply any other information of the file!!.

i am a little confused because i feel that somewhere i need the path of the file in order to read it
not just the name of the file, otherwise i must know in which folder it resides(maybe in the same folder as the assembler) !!

any help to make this clear to me would be appreciated.


just in case: i'm using java as a programming language.

thanks,
bader.
Reply | Threaded
Open this post in threaded view
|

Re: running the assembler

cadet1620
Administrator
bader wrote
i am a little confused because i feel that somewhere i need the path of the file in order to read it
not just the name of the file, otherwise i must know in which folder it resides(maybe in the same folder as the assembler) !!
You should consider the argument to your assembler to be a path and filename. For example
    asm somewhere/file.asm
should produce the output file "somewhere/file.hack".

The I/O library will handle paths passed into its open functions based on the current working directory.

This way, your working directory can be the directory where you are developing your assembler and you can test it using full paths to the test sources.

Alternatively, you can add the directory where your assembler's executable is stored to your PATH variable so that it can be run when the working directory is the source file's directory.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: running the assembler

bader
Thank you.