Zack's CPU Machine Code

BASIC and Assembly are both converted into machine code before they can run. It supports loading binary files if you want to make a compiler/language for it.

Syntax:

Standard:

in Binary: OOOOOOOO AAAAAAAA AAAAAAAA

O - opcode
A - address/argument

LD*, EX*A, and EX*V:

in Binary: OOOOOOOO AAAAAAAA AAAAAAAA LLLLLLLL

O - opcode
A - address/argument
L - number of bits to copy

OP Codes:

Legend:

ABBREVIATION

Full name

Op Code

What it does

NOP

No Operation

0x0

Does nothing for one tick.

MOVA

Move A

0x1

Sets the A register to the argument.

MOVB

Move B

0x2

Sets B to the argument

MOVC

Move C

0x3

Sets C to the argument

MOVF

Move F

0x6

Sets F to the argument

ADDA

Add Address

0x7

Adds A to the value at the specified address

ADDV

Add Value

0x8

Adds the argument to A

SUBA

Subtract Address

0x9

Subtracts the value at the specified address from A

SUBV

Subtract Value

0xA

Subtracts the argument from A

MULA

Multiply Address

0xB

Multiplies A by the value at the specified address

MULV

Multiply Value

0xC

Multiplies A by the argument

DIVA

Divide Address

0xD

Divides A by the value at the specified address

DIVV

Divide Value

0xE

Divides A by the argument

ANDA

And Address

0xF

ANDs B with the value at the specified address

ANDV

And Value

0x10

ANDs B with the argument

ORA

Or Address

0x11

ORs B with the value at the specified address

ORV

Or Value

0x12

ORs B with the argument

NOT

Not

0x13

Flips all of B's bits

XORA

Exclusive Or Address

0x14

XORs B with the value at the specified address

XORV

Exclusive-Or Value

0x15

XORs B with the argument

CMPA

Compare Address

0x16

Compares C to the value at the specified address, and sets flags accordingly

CMPV

Compare Value

0x17

Compares C to the argument, and sets flags accordingly

BRGT

Branch if Greater Than

0x1A

If the argument was greater than C during CMPR, go to specified address

BRLT

Branch if Less Than

0x1B

If the argument was less than C during CMPR, go to specified address

BRGE

Branch if Greater or Equal

0x1C

If the argument was greater than or equal to C during CMPR, go to specified address

BRLE

Branch if Less or Equal

0x1D

If the argument was less than or equal to C during CMPR, go to specified address

BRNZ

Branch if Not Zero

0x1E

If C is not zero, go to specified address

BREZ

Branch if Equal to Zero

0x1F

If C is equal to zero, go to specified address

GOTO

Go to

0x20

Continues execution at the specified address

LDAV

Load A Value

0x21

Sets A to the value at the specified address

LDBV

Load B Value

0x22

Sets B to the value at the specified address

LDCV

Load C Value

0x23

Sets C to the value at the specified address

LDFV

Load F Value

0x24

Sets F to the value at the specified address

EXAA

Export A Address

0x27

Exports A to the address in the specified address

EXBA

Export B Address

0x28

Exports B to the address in the specified address

EXCA

Export C Address

0x29

Exports C to the address in the specified address

EXFA

Export F Address

0x2A

Exports F to the address in the specified address

EXAV

Export A Value

0x2B

Exports A to the specified address

EXBV

Export B Value

0x2C

Exports B to the specified address

EXCV

Export C Value

0x2D

Exports C to the specified address

EXFV

Export F Value

0x2E

Exports F to the specified address

GOSUB

Go to subroutine

0x2F

A GOTO that expects a RETURN

RETURN

Return

0x30

Returns from a subroutine

LDAA

Load A Address

0x31

Load the value at the address stored at the specified address.

LDBA

Load B Address

0x32

Load the value at the address stored at the specified address.

LDCA

Load C Address

0x33

Load the value at the address stored at the specified address.

LDFA

Load F Address

0x34

Load the value at the address stored at the specified address.

LSLA

Logical Shift Left Address

0x35

Shift A's bits left by the value at the specified address.

LSRA

Logical Shift Right Address

0x36

Shift A's bits right by the value at the specified address.

ASLA

Arithmetic Shift Left Address

0x37

Shift A's bits left by the value at the specified address.

ASRA

Arithmetic Shift Right Address

0x38

Shift A's bits left by the value at the specified address.

LSLV

Logical Shift Left Value

0x39

Shift A's bits left by the operand.

LSRV

Logical Shift Right Value

0x3A

Shift A's bits right by the operand.

ASLV

Arithmetic Shift Left Value

0x3B

Shift A's bits left by the operand.

ASRV

Arithmetic Shift Right Value

0x3C

Shift A's bits left by the operand.

PUSH

Push

0x3D

Pushes the value at the specified address onto the stack.

POP

Pop

0x3E

Pops the most recent item off the stack, and places it in the specified address.

DEC

Decrement

0x3F

Subtracts 1 from the value at the specified address.

INC

Increment

0x40

Adds 1 to the value at the specified address.

CLEQ

Call If Equal

0x41

CALLs the specified address if A is 0.

CLNE

Call If Not Equal

0x42

CALLs the specified address if A is not 0.

CLGT

Call If Greater Than

0x43

CALLs the specified address if A is greater than 0.

CLLT

Call If Less Than

0x44

CALLs the specified address if A is less than 0.

CLGE

Call If Greater Or Equal

0x45

CALLs the specified address if A is greater than or equal to 0.

CLLE

Call If Less Or Equal

0x46

CALLs the specified address if A is less than or equal to 0.

CLEAR

Clear

0x47

Zero memory between A, and A + the argument.