Skip to content

MJDaws0n/Novus

Repository files navigation

Novus

NOTE: This is in very early development and may be very buggy and may not work on some os's or cpu's at all

This may be used for my a-level project, therefore there are many references to clients and such.

The aim in the short future is to re-write novus, in novus!

Quick install

Run the following to install the latest version automatically:

curl -fsSL https://raw.githubusercontent.com/MJDaws0n/novus/main/install.sh | bash

Or manually:

  1. Download the latest binary for your platform from the releases tab.
  2. Copy it to your PATH:
sudo cp "novus_download" /usr/local/bin/novus
sudo chmod +x /usr/local/bin/novus
# macOS only:
sudo xattr -d com.apple.quarantine /usr/local/bin/novus

Build your first app

It's suggested you use the offical novus package manager nox, however it's not required.

Using nox

  1. Download and install nox
  2. Run the following command in the folder you wish to use '''sh nox init '''
  3. Import the standard library
nox pull std
  1. Write your first app by edditing the main.nov file
module novus_example

// Import standard lib as std
// Use import lib/std; to import without std prefix
import lib/std std;

fn main() -> i32 {
    // Print something
    std.print("Hello World!");

    // Exit program
    std.exit(0);
    return 0;
}
  1. Build to an executable
novus main.nov

Without using nox - with libraries

  1. Download the std package, or copy the functions for the respective operating system from here
  2. Create a novus file and add your code.
module novus_example

// Import standard lib as std
// Use import lib/std; to import without std prefix
import lib/std std;

fn main() -> i32 {
    // Print something
    std.print("Hello World!");

    // Exit program
    std.exit(0);
    return 0;
}
  1. Build to an exectuabl
novus your_file.nov

Without using nox - without libraries

  1. Create a novus file and add your code.
module novus_example

fn main() -> i32 {
    // Print something
    print("Hello World!");

    // Exit program
    exit(0);
    return 0;
}

// Define a print function for macos silicon
fn print(msg: str) -> void {
    msg = msg + "\n";
    mov(x0, 1);
    mov(x1, msg);
    mov(x2, len(msg));
    mov(x16, 0x2000004);
    syscall();
}

// Deffine an exit function for macos silicon
fn exit(code: i32) -> void {
    mov(x0, code);
    mov(x16, 0x2000001);
    syscall();
}
  1. Build to an exectuable
novus your_file.nov

Novus syntax and built in functions

Take a look at novus syntax and built in functions here Take a look at novus libraries here

Existing projects in novus

Build and run

go run cmd/novus/main.go --target=linux/amd64 example_old_lib_examples/example.nov

Target output directories

Novus writes artifacts to build/<target>/ using these target directory names:

  • darwin_arm64
  • linux_x86_64
  • linux_x86
  • linux_arm64
  • windows_x86_64

Cross-compilation toolchain notes

  • linux/amd64 and linux/386 use NASM + ld.
  • linux/arm64 needs aarch64-linux-gnu-as and aarch64-linux-gnu-ld when compiling from a non-ARM64 host.
  • windows/amd64 needs NASM + GoLink (or link.exe).
  • darwin/arm64 linking requires macOS tooling (as/ld) or an installed Darwin cross-toolchain.

See novus_docs.md for full language/CLI reference and a complete platform section.

New example apps and libraries

A modern, reusable example set now lives in examples/:

  • Apps:
    • examples/apps/hello-matrix/main.nov
    • examples/apps/dice-duel/main.nov
    • examples/apps/string-lab/main.nov
    • examples/apps/portable-sanity/main.nov
  • Libraries:
    • examples/lib/core/main.nov
    • examples/lib/game/main.nov
    • examples/lib/term/main.nov

Build and run examples (Linux host):

novus --target=linux/amd64 examples/apps/hello-matrix/main.nov
./build/linux_x86_64/hello_matrix
novus --target=linux/amd64 examples/apps/dice-duel/main.nov
./build/linux_x86_64/dice_duel

Library documentation

Reproducible test script

Run the end-to-end example and cross-target checks:

chmod +x scripts/run-example-matrix.sh
NOVUS_BIN=/home/max/.local/bin/novus ./scripts/run-example-matrix.sh

About

A structured assembly language.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors