ALMOND

v6.1

Assembly Language MONitor Definitiveultrararepremiumplus

Syntax:

Standard:

COMMAND (space or tab) ARGUMENT

LDA/EXPA:

EXPA.LENGTH (space or tab) ADDRESS

for example: LDA.8 to load 1 byte, EXPA.16 to export 2 bytes

# or $ is hex
& is decimal
! is binary
@ is pointer

Examples:

Basic Looping Program

Loop:
; Add the argument to the A register
ADD #1
GOTO Loop

More Advanced Program

Adds to B until B and C are equal, then adds to C.

MOVB #0
MOVC &10

Compare:
INC B
LDA B
; CMPR will compare the operand/variable to the A register, preparing for a branch.
CMPR C
; BREQ - Branch if A and the argument were equal
BREQ AddToC
GOTO Compare

AddToC:
LDA C
ADD &10
LDC A
GOTO Compare

BIOS:

I'm still working on the BIOS, right now it only supports one-letter commands

R

Read from an address formatted in hex

W

Write to an address formatted in hex

>R 5FFC
034E
>W 5FFC F000
>R 5FFC
F000

Registers

Replace * with any of the following: A,B,C,F

MOV*

Sets a register to a value

LD*

Loads a value from an address

EXP*

Exports a register to an address

; MOVA - Set the A register to a value
; After this operation the A register will hold 0

MOVA #0

; LDA - Load from an address in RAM.
; After this operation, the A register will hold the value that is stored in address #4000

LDA.8 #4000

; EXPA - Export the A register to an address in RAM.
; After this operation #3000 will hold the value of A
; Since it's .16 it'll export a short, and both #3000 and #3001 will have changed

EXPA.16 #3000

A - The Accumulator:

This register is what most of the commands operate on. Most of the commands have two versions, one that takes the value directly, and one that takes an address to look for the value. The @ operator will override which one is used


Math operations

ADD

Adds the argument to A

SUB

Subtracts the argument from A

MUL

Multiplies A by the argument

DIV

Divides A by the argument

INC

Adds 1 to the argument address

DEC

Subtracts 1 from the argument address


Bit-wise operations

AND

ANDs A against the argument

OR

ORs A against the argument

NOT

Flips all of A's bits. Doesn't take an argument

XOR

XORs A against the argument

LSL

Logical Shift Left, shifts the bits of A left, including the sign bit

LSR

Logical Shift Right, shifts the bits of A right, including the sign bit

ASL

Arithmetic Shift Left, shifts the bits of A left, preserving the sign bit

ASR

Arithmetic Shift Right, shifts the bits of A right, preserving the sign bit


Comparing

CMPR

Compares the argument to A through subtraction, you know if they are equal when A is 0 after this operation, the sign determines wether it's less than or greater

Use one of these functions to branch:

BRGT

GOTO argument address if A is greater than 0

BRLT

GOTO argument address if A is less than 0

BREQ

GOTO argument address if A is equal to 0

BRNE

GOTO argument address if A is not 0

BRGE

GOTO argument address if A is greater than or equal to 0

BRLE

GOTO argument address if A is less than or equal to 0

CLGT

CALL argument address if A is greater than 0

CLLT

CALL argument address if A is less than 0

CLEQ

CALL argument address if A is equal to 0

CLNE

CALL argument address if A is not 0

CLGE

CALL argument address if A is greater than or equal to 0

CLLE

CALL argument address if A is less than or equal to 0

string: "IS A GREATER THAN C"
yeah: "YEAH"
no: "NO"
MOVB string
CALL PrintString
MOVC &100
MOVA &50
CMPR C
BRLT SayNo
MOVB yeah
GOTO PrintResult
SayNo:
MOVB no
PrintResult:
CALL PrintString

Labels:

Labels are a way of naming a spot in the code, for referencing in a GOTO or CALL

Loop:
GOTO Loop

Variables

Variables are labels that point at a number

myVar: #1

It's reserving a spot in the code to store a variable, so use a GOTO to skip the variables in execution.

GOTO Main
x: #1
y: "Hello World!"
Main:

integers are 16 bits each, equivalent to a C short

Pointers:

@ is the pointer operator, where you place it decides whether it's the address-of or pointer-to operator

; Load the value in var
LDA var
; Load from the address stored in var
LDA var@
; Load the address of var, it's the same as MOVA var
LDA @var

Macros:

Macros create a substitution for some other text, which is replaced before being compiled

MACRO MyMacro PRINT
MyMacro "Hello World!"

MACRO Cheese LDA
MACRO Burger #4FEE
Cheese Burger

CPU Stack:

PUSH

pushes the given value onto the stack

POP

pops the top item from the stack, and places that value in the given address

Execution:

GOTO/JMP

Goes to argument address or label

CALL

A GOTO that waits for a RTN (aka pushes the current address onto the pointer stack)

RTN

Return (aka GOTO the current address on the pointer stack.)

MOVA #0
CALL Adder
GOTO SomewhereElse

Adder:
ADD #1
RTN

NOP

No operation. Takes no argument