Skip to content
/ ngaro Public

An embeddable implementation of the Ngaro Virtual Machine for Go programs

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE-RETRO
Notifications You must be signed in to change notification settings

db47h/ngaro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Go Report Card GoDoc

Ngaro Go

This is an embeddable Go implementation of the Ngaro Virtual Machine.

This repository contains the embeddable virtual machine, a rudimentary symbolic assembler for easy bootstrapping of projects written in Ngaro machine language, and the retro command line tool that can be used as a replacement for the Retro reference implementations.

Please visit http://forthworks.com/retro/ to get you started about the Retro language and the Ngaro Virtual Machine.

The main purpose of this implementation is to allow customization and communication between Retro programs and Go programs via custom opcodes and I/O handlers (i.e. scripting Go programs in Retro). The package examples demonstrate various use cases. For more details on I/O handling in the Ngaro VM, please refer to http://retroforth.org/docs/The_Ngaro_Virtual_Machine.html.

Custom opcodes are implemented by intercepting implicit calls to negative memory addresses. This limits the total addressable memory to 2GiB on 32 bits systems, but this also allows the VM to be fully backwards compatible with existing Retro images while still providing enhanced capabilities.

This implementation passes all tests from the retro-language test suite and its performance when running tests/core.rx is slightly better than with the reference implementations:

1.12s for this implementation, no custom opcodes, compiled with Go 1.7.
1.30s for the reference Go implementation, compiled with Go 1.7
2.22s for the reference C implementation, compiled with gcc-5.4 -O3 -fomit-frame-pointer

For all intents and purposes, the VM behaves according to the specification. This is of particular importance to implementors of custom opcodes: the VM always increments the PC after each opcode, thus opcodes altering the PC must adjust it accordingly (i.e. set it to its real target minus one).

About

An embeddable implementation of the Ngaro Virtual Machine for Go programs

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE-RETRO

Stars

Watchers

Forks

Packages

No packages published