Skip to content

Assembly

Infinity edited this page Jun 25, 2023 · 2 revisions

Introduction

This page describes the Syntax and features of the i16 ASM Dialect. Please refer back to here regularly to see updates to the Dialect, when Assembler updates occur.

Please adhere to the strict Syntax to avoid teething pains with the Assembler, Thank you!

Syntax

[ins][cond] [meta] [args]
Instruction Mnemonics and Conditions share the same word in i16 ASM, creating a compound mnemomic like 'incuc' (Increment Unconditional). Any additional information about the instruction, such as flag usage, carry usage and instruction width, requires use of the [meta] word.

The [meta] word is an optional word declared with an ! prefix, this is where you declare instruction flags. It was setup like this for ease of reading and assembler creation - as reading addsh !fcw is a bit easier than addshfcw, which is all flags enabled on a Signed Higher conditional Add. The flags you can declare in this [meta] word is:

  • F - Flags, denotes whether the instruction updates flags.
  • C - Carry, denotes whether the instruction utilises the Carry bit.
  • W - Width, denotes the data width of the instruction. The Width flag does not have to be declared for the assembler to create 16-bit instructions, as the assembler will implicitly determine width from register or immediate arguments provided, i.e. if you select a higher or lower byte of a Register, it will set it to be 8-bit.

Prefixes

i16 ASM makes use of prefixes to determine data types. The prefixes in use are:

  • ! - Denotes Instruction Metadata (can only have one and must be in the second word)
  • % - Denotes Addresses
  • $ - Denotes Immediates

Group-specific Syntax

ARH - Arithmetic and Logic Group

Any Instructions that take a Destination Register optionally may have them as a third argument, but a Destination must be declared when using a Immediate in the first argument (main) as Destination is implicitly assumed to be the register in the first argument if not declared - failing to do so will result in the assembler printing an error and exiting!