Skip to content

Latest commit

 

History

History
200 lines (111 loc) · 4.01 KB

index.md

File metadata and controls

200 lines (111 loc) · 4.01 KB

SBTCVM Assembly v3.x Documentation

special note: this is incomplete, also see opcodes.txt and iobus.txt in parent directory...

Introduction

SBTCVM Assembly v3, also known as G2ASM or tasm, Is an advanced listing-style assembler for the SBTCVM Gen2-9 virtual machine.

Basic Syntax

normal keywords

a normal keyword is for the most part any keyword that translates to a CPU Opcode.
Normal keywords support the following argument types:

Ternary Integers

two notations are supported +0- and p0n notations. up to 9 trits may be specified.

setreg1;+++---000
setreg2;pppnnn000

Decimal Values

In order to use decimal values you must prefix them with 10x similar to 0x when working with hexadecimal numbers in many binary languages.

setreg1;10x12
setreg2;10x-12

Balanced Septemvigesimal Values

you must prefix Septemvigesimal values with the 27! prefix: for refrence, MMM is -9841 and DDD is 9841. remember gen 2 doesn't support values outside that range!

1 septemvigesimal digit = 1 triad = 3 trits.

Any combination of 3 septemvigesimal digits will work.

setreg1;27!MMM
setreg1;27!DDD

Balanced Nonary Values

you must prefix Septemvigesimal values with the 9! prefix: for refrence, ZWWWW is -9841 and 14444 is 9841. remember gen 2 doesn't support values outside that range!

1 Nonary digit = 2 trits.

Any combination of 4 Nonary digits will work.

Due to integer range limits, the 5th digit may ONLY be 1, 0, or Z!

setreg1;9!ZWWWW
setreg1;9!14444

Character Values

use character values. any plain character supported by SBTCVM-BTT2 encoding can be used when prefixed via a : (colon).

setreg1;:C

the following characters require escape sequences:

ASCII escape sequence in assembly
newline \n
null \0
backspace \x
vertical bar \v
; \c
\ \\
space \s
# \p
, \m

Namespace variable references

(see Next Section for what these are...)

setreg1;>my_namespace_var
goto;>my_label

Namespace Variables

A unified system for labels, and compile-time constants, that lies at the heart of the assembler's automatic address system.

Labels

any normal keyword can be given a label by appending one via a second semicolon ;

setreg1;10x1;my_label

custom namespace variables

you can create your own namespace variables from raw values like this:

v>my_namespace_var;10x0
v>another_one;+0-
v>and_yet_another;:R

misc non-opcode keywords

These keywords don't generate opcodes, but are still useful for specific things.

zerosize

zerosize is a special assembler keyword, that, like its name suggests, is zero in size.

its mainly intended for compilers, when performing a goto to the next instruction, when its generated by separate code.

if;>skip
goto;>somewhere
zerosize;;skip

if the following code existed afterwards...

goto;>somewhere_else

then the jump to zerosize, would actually jump directly to the latter instead.

marker

print out the address, source line number, and a plaintext name, at a given point in Assembly code

marker;example marker

this is also easily integrated into compilers that target SBTCVM Assembly.

header variables

SBTCVM Assembly's header variables control various properties on how the assembler treats your code.

assembler mode

(not valid in tas0 files)

trom mode (default)

head-mode=trom

variable-only mode (do not output ROM, handy for .nsp libraries

head-mode=vars

nsp include

(can be used multiple times for multiple nsp libraries) (supported in tas0 files)

heres's how to include the standard nsp library (contains IObus constants mainly)

head-nspin=stdnsp

nsp output flag

(not valid in tas0 files)

to enable nsp file output:

head-nspout=1

override automatic nsp file basename

(not valid in tas0 files)

head-nspname=name

override automatic TROM file basename

(not valid in tas0 files)

head-rname=name