Skip to content

Latest commit

 

History

History
332 lines (281 loc) · 4.99 KB

Software.md

File metadata and controls

332 lines (281 loc) · 4.99 KB

↩ Return

Software

Machine code

ci sm zx nx zy ny f no a d *a lt eq gt
1 0 0 0 1 0 1 0 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
1 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

Machine code

Assembler Language

# Assembler code 
loop:
A = 0x7FFF
*A = *A+1
*A = *A+1
A = loop
JMP

_~ not ready yet ~_

Assembler program

pass

_~ not ready yet ~_

Escape Labyrinth

begin:
A = 0x7FFF
D = *A
A = 255
D = D - A
A = begin
D - 1; JGT
A = 0x7FFF
D = *A
A = 255
D = D - A
A = tl
D - 1; JEQ
fw:
A = 4
D = A
A = 0x7FFF
*A = D + *A
A = begin
JMP
tl:
A = 8
D = A
A = 0x7FFF
*A = D + *A
A = begin
JMP

Escape Labyrinth

Display

A = 0x4000
D = A
*A = D
A = A + 1
*A = D
A = 0x4200
*A = D

Network

pass

Stack machine

Init stack

Name Number
SP 0
A = 0x0100
D = A
A = SP
*A = D

Push D

A = SP
A = *A
*A = D
A = SP
*A = *A+1

Pop D

A = SP
*A = *A-1
A = *A
D = *A

Pop A

A = SP
*A = *A-1
A = *A
A = *A

Push Value

A = value
D = A
PUSH_D

Add

POP_D
POP_A
D = D + A
PUSH_D

Sub

POP_D
POP_A
D = A - D
PUSH_D

Neg

POP_A
D = -A
PUSH_D

And

pass

Or

pass

High-level language

Tokenize

Type Match Grammar Name
Pattern [ ]+ Ignore
Pattern [0-9]+ Name Number
Exact + Literal
Exact - Literal
Exact ( Literal
Exact ) Literal

Grammar

Symbol Expression
PROGRAM Expression
Expression Expression + Number
Expression Number
Expression Expression - Number
Expression ( Expression )
Expression Number - Expression
Expression Number + Expression
Expression - Expression

Code generation

PROGRAM Expression

Expression Expression + Number

[Expression]
PUSH_VALUE [Number]
ADD

Expression Number

PUSH_VALUE [Number]

Expression Expression - Number

[Expression]
PUSH_VALUE [Number]
SUB

Expression ( Expression )

[Expression]

Expression Number - Expression

PUSH_VALUE [Number]
[Expression]
SUB

Expression Number + Expression

PUSH_VALUE [Number]
[Expression]
ADD

Expression - Expression

[Expression]
NEG

Conditionals

Eq

_~ not ready yet ~_

Gt

_~ not ready yet ~_

Lt

_~ not ready yet ~_

Not

_~ not ready yet ~_

Goto

_~ not ready yet ~_

If-goto

_~ not ready yet ~_

Memory

Push Memory

_~ not ready yet ~_

Pop Memory

_~ not ready yet ~_

Push Static

_~ not ready yet ~_

Pop Static

_~ not ready yet ~_

Functions

_~ not ready yet ~_

Call

_~ not ready yet ~_

Function

_~ not ready yet ~_

Return

_~ not ready yet ~_

Push argument

_~ not ready yet ~_

Pop argument

_~ not ready yet ~_

Push local

_~ not ready yet ~_

Pop local

_~ not ready yet ~_