Skip to content

πŸ’» β€’ NewASM is an interpreted low-level programming language which combines explicit memory and register control, giving it a breeze of assembly-like feel, with high-level functionalities such as objects, threads and more.

License

Notifications You must be signed in to change notification settings

bracesoftware/newasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

826 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Welcome to the NewASM Wiki

Language Issues Pull Requests Downloads License

Interpreted Low-Level Language that Mimics Assembly

NewASM is an interpreted low-level programming language which combines explicit memory and register control, giving it a breeze of assembly-like feel, with high-level functionalities such as objects, threads and more.

Note

NewASM language runs inside a NewASM Virtual Machine.

Documentation

Below is the simple Hello World program written in New-Assembly.

using "ios"
.data
    string text : "Hello world\n"
    intg len : $-text
.start
    mov tlr, text
    mov fdx, 1
    mov bos, len

    sysenter "ios"
    
    syscall

    ret 0

Warning

The wiki is being completely reworked, so it may be missing some stuff.

NewASM allows you to write semi-efficient low-level programs in one universal assembly-like language. This language features many things immediatelly out-of-the-box such as concurrency, thread channels, basic crypto, file, math and console functionality, etc., so you do not have to worry about any library installation. However, if you wish to add any new functionality, you can easily integrate dynamic libraries (DLLs, SOs) into your project.

Since NewASM runs in a virtual machine, it is thus running in a fully controlled sealed environment, so it is great for learning and experimenting.

Table of contents

Using the executeable

NewASM build consists of 2 programs, newasm and nprogwin. What YOU need is the newasm executable file which may be run in 2 modes. Arguments are provided using the newasm_args variable you create before running the executeable, ergo:

  1. Windows
set newasm_args=arg1,arg2
  1. Linux
export newasm_args=arg1,arg2
Argument Parameters Description
h - Displays help about these commands.
l - Turn on the logging system.
nv - Disable version checking.
std - Use the standard library.
nodbg - Disable the debug window.
out <binary name> Provide binary name for the compiler, default is a.out. This is argument is useful only in compiler/interpreter mode.

Example:

set newasm_args=l,h,std,out=app

Launch modes

When running the newasm executeable, you can run it in 2 different modes:

  • shell: this is the shell/control console mode, the core of the virtual machine - application will run as the command prompt with its own commands, you can install packages and maintain your project;
  • compiler/interpreter: this mode is used for developing applications - linking libraries and files, generating reusable binaries, testing the app and getting profiler information.

To run the interpreter, use newasm <filename>.asm, but to run the shell, just run the newasm app.

Note

To read more about configuring your NewASM application, click here...


Shell mode

Shell mode brings commands with it. The shell mode is the PRIMARY mode for end users. Basically the "operating system" for the virtual machine. Below is a list of available commands:

Command Arguments Description
help - Displays this panel within the console.
exit - Closes the application.
repl - Enter the read-evaluate-print console.
install <lib> Install a library online (currently there's no libraries that are available!).
login - Log into your local account.
logout - Log out of your local account.
addenv - Adds an environment variable.
remenv - Deletes an environment variable.
modenv - Modifies the environment variable.
renenv - Changes the variable name.
printenv - Prints all the environment variables.
passwd - Change your password.
usernm - Change your username.
mount <setup name> Mount a pre-installed setup. Use mount ? to see a list of available setups.
run <binary name> Run a compiled NewASM application.
perf - Display performance details about the last application you ran.
usestd - Enable the std flag.

Compiler/interpreter mode

Compiler/interpreter mode compiles and runs your application through several phases.

  1. Linker phase: In this phase, the linker links all files included in the application into one internal format.
  2. Internal compilation: In this phase, the system tokenizes and resolves some compile-time stuff before running the program. This ensures safe and stable program execution. In this phase, the system is telling the virtual machine what kernel modules will be used during the execution of the program.
  3. Binary format generation: In this phase, the compiler spews out the binary for your app. Links the dynamic libraries you provided in the project file. This binary can be then reused in the shell.
  4. Execution: Final phase (used for app devs), the system runs the compiled code!

Tip

We're planning to add JIT compilation into native code, but that's in the testing phase.

Note

Click here... to read more about compile-time instructions/directives.


The language

This section of the wiki provides a deep walkthrough of the language itself.

Table of contents


Code sections

NewASM code is, as in other assemblers, divided into different sections that have their own syntax. There are 4 different sections and each one has a different purpose:

  1. .start - this is the code section that contains functional code (instructions), can contain procedure (function) and thread definitions;
  2. .data - this is where you declare your variables, references, containers, and more;
  3. .text - this is where you declare macros.

You change a section by doing:

.section_name

For example:

.start
    ; code
.data
    ; declarations
    ; etc...

Storing data into variables and containers

In NewASM there's a huge variety of built in variable types and data containers. Read more...


Available instructions

NewASM features many instructions, around 70 of them. Here is a list:

  1. Data manipulation instructions
  2. Manual memory allocation instructions
  3. Kernel-related instructions
  4. Execution flow instructions
  5. Miscellaneous instructions
  6. Mathematical instructions and bit operations
  7. Thread-related instructions
  8. Union-related instructions
  9. Switch block instructions
  10. I/O port-related instructions

Language concepts

NewASM features different concepts such as decorators, namespaces, primitive classes and more advanced stuff.

  1. Decorators
  2. Namespaces
  3. Lambda procedures
  4. Environment variables
  5. Events
  6. Sealed labels

Other resources

This is a list of extra resources that might help.

  1. Error exit codes
  2. Calling external libraries (DLLs, SOs)
  3. Interesting examples

About

πŸ’» β€’ NewASM is an interpreted low-level programming language which combines explicit memory and register control, giving it a breeze of assembly-like feel, with high-level functionalities such as objects, threads and more.

Resources

License

Contributing

Stars

Watchers

Forks

Languages