#概要
plunkerでassembler-simulatorやってみた。
命令セット調べてみた。
#転送命令
MOV reg, reg regA = regB
MOV reg, address reg = address
MOV reg, constant reg = constant
MOV address, reg address = reg
MOV address, constant address = constant
#ビット操作命令
AND reg, reg regA = regA and regB
AND reg, address reg = reg and address
AND reg, constant reg = reg and constant
OR reg, reg regA = regA or regB
OR reg, address reg = reg or address
OR reg, constant reg = reg or constant
XOR reg, reg regA = regA xor regB
XOR reg, address reg = reg xor address
XOR reg, constant reg = reg xor constant
NOT reg reg = !reg
#算術命令
ADD reg, reg regA = regA + regB
ADD reg, address reg = reg + address
ADD reg, constant reg = reg + constant
SUB reg, reg regA = regA xor regB
SUB reg, address reg = reg + address
SUB reg, constant reg = reg + constant
INC reg reg = reg + 1
DEC reg reg = reg - 1
MUL reg A = A * reg
MUL address A = A * address
MUL constant A = A * constant
DIV reg A = A / reg
DIV address A = A / address
DIV constant A = A / constant
#シフト命令
SHL reg, reg reg = reg >> reg
SHL reg, address reg = reg >> address
SHL reg, constant reg = reg >> constant
SHR reg, reg reg = reg << reg
SHR reg, address reg = reg << address
SHR reg, constant reg = reg << constant
#比較命令
CMP reg, reg flag = regA cmp regB
CMP reg, address flag = reg cmp address
CMP reg, constant flag = reg cmp constant
#分岐命令
JC Carry = TRUE
JNC Carry = FALSE
JZ Zero = TRUE
JNZ Zero = FALSE
JA Carry = FALSE && Zero = FALSE
JNBE Carry = FALSE && Zero = FALSE
JAE Carry = FALSE
JNB Carry = FALSE
JB Carry = TRUE
JNAE Carry = TRUE
JBE Carry = TRUE or Zero = TRUE
JNA Carry = TRUE or Zero = TRUE
JE Zero = TRUE
JNE Zero = FALSE
#コール命令
CALL address
RET
#スタック命令
PUSH reg
PUSH address
PUSH constant
POP reg
#その他命令
HLT
#補足
レジスタは、4つ。A、B、C、D 8bit。
8bitCPUと256byteのメモリで構成されています。
すべての命令と変数はメモリ内に収まる必要があります。
すべての命令とオペランドは1byteです。
MOV命令は3byteのメモリを使用します。
0xE8から0xFFにメモリマップされたコンソール出力があります。
スタックは、メモリの外の様。
以上。