Nano VM has four binaries: the VM: nanovm, the compiler: nanoc, the assembler: nanoa and the graphics/GUI server: flow. To run them you have to set an ENV variable (NANOVM_ROOT) to the path where the Nano VM directory is. The Nano VM directory should look like this:
bin/ linux-x86-64 windows-x86-64 ... download/ fonts/ home/ include/ lib/ np/ prog/ sound/ src/ toolchain/
If the NANOVM_ROOT ENV variable is set, the programs know where to find the needed directories. On the other side the VM can be runned as a portable “installation” from a USB stick for example. If you want to do this, then you have to note the following:
If the program names begin with “port” the programs can be runned from the bin/platform directory. So the executables there should be called:
portnanoa portnanoc portnanovm portflow
Here is the famous “Hello world!” program (hello.nanoc) in the N language:
func main () int one = 1; int ret = 0; print "Hello world!"; printn one; exit ret; funcend
To compile the N program open a shell, change to the “nanovm/prog” directory and start the compiler:
$ nanoc hello
And you will see something like this:
nanoc 64 bit 1.6.2 (c) 2017 by Stefan Pietzonke firstname.lastname@example.org -== free software: GPL/MPL ==- compiled by clang version: 3.9.1 on Aug 15 2017 loading program: hello.nanoc ok saving program: hello.na emit_code: opcodes: 13 ok
Now run the assembler:
$ nanoa hello
And you will see:
nano assembler 64 bit 3.4.4 (c) 2017 by Stefan Pietzonke email@example.com -== free software: GPL/MPL ==- compiled by clang version: 3.9.1 on Aug 15 2017 loading program: hello.na ok saving program: hello.no 548 bytes object file saved ok
So everything is fine! Now run the “hello.no” object file:
$ nanovm hello
Finally the “Hello world!” program runs:
nano vm 64 bit 3.4.4 (c) 2017 by Stefan Pietzonke firstname.lastname@example.org -== free software: GPL/MPL ==- -== dthreading ==- ============== compiled by clang version: 3.9.1 on Aug 15 2017 threading: CPU cores: 0 - 3 dynamic SET at runtime hyperthreading CPU affinity setting: ON loading program: hello.no ok Hello world!
Sometimes you want just the plain output of your program without startup messages:
$ nanovm hello -q
You just finished your first program!
Now edit the program to show a different text!