Handbook
Glossary
patterns ( -- hashtable )
Vocabulary
cpu
.
8080
.
emulator
Inputs
None
Outputs
hashtable
an
object
Definition
USING:
accessors
kernel
math
;
IN:
cpu.8080.emulator
:
patterns
( -- hashtable )
H{
{
"JP-(RR)"
[
[
$1
]
keep
pc<<
]
}
{
"LD-(NN),RR"
[
[
$1
]
keep
[
next-word
]
keep
write-word
]
}
{
"OR-N"
[
[
a>>
]
keep
[
next-byte
]
keep
[
or-byte
]
keep
a<<
]
}
{
"RST-28H"
[
40
swap
(emulate-RST)
]
}
{
"PUSH-RR"
[
[
$1
]
keep
push-sp
]
}
{
"RST-10H"
[
16
swap
(emulate-RST)
]
}
{
"RST-20H"
[
32
swap
(emulate-RST)
]
}
{
"NOP"
[
drop
]
}
{
"RET-F|FF"
[
dup
$1
[
6
over
inc-cycles
ret-from-sub
]
[
drop
]
if
]
}
{
"EX-RR,RR"
[
[
$1
]
keep
[
$3
]
keep
[
$2
]
keep
$4
]
}
{
"RRA"
[
(emulate-RRA)
]
}
{
"SBC-R,(RR)"
[
[
$1
]
keep
[
$3
]
keep
[
read-byte
]
keep
[
sub-byte-with-carry
]
keep
$2
]
}
{
"LD-(RR),R"
[
[
$3
]
keep
[
$1
]
keep
write-byte
]
}
{
"OR-R"
[
[
a>>
]
keep
[
$1
]
keep
[
or-byte
]
keep
a<<
]
}
{
"RST-18H"
[
24
swap
(emulate-RST)
]
}
{
"LD-(RR),N"
[
[
next-byte
]
keep
[
$1
]
keep
write-byte
]
}
{
"XOR-N"
[
[
a>>
]
keep
[
next-byte
]
keep
[
xor-byte
]
keep
a<<
]
}
{
"AND-(RR)"
[
[
a>>
]
keep
[
$1
]
keep
[
read-byte
]
keep
[
and-byte
]
keep
a<<
]
}
{
"ADD-RR,RR"
[
[
$1
]
keep
[
$3
]
keep
[
add-word
]
keep
$2
]
}
{
"XOR-R"
[
[
a>>
]
keep
[
$1
]
keep
[
xor-byte
]
keep
a<<
]
}
{
"RLCA"
[
(emulate-RLCA)
]
}
{
"POP-RR"
[
[
pop-sp
]
keep
$2
]
}
{
"SCF"
[
carry-flag
swap
cpu-f-bitor=
]
}
{
"INC-(RR)"
[
[
$1
]
keep
[
read-byte
]
keep
[
inc-byte
]
keep
[
$1
]
keep
write-byte
]
}
{
"DI"
[
[
255
interrupt-flag
-
]
swap
cpu-f-bitand
]
}
{
"OR-(RR)"
[
[
a>>
]
keep
[
$1
]
keep
[
read-byte
]
keep
[
or-byte
]
keep
a<<
]
}
{
"DEC-RR"
[
[
$1
]
keep
[
dec-word
]
keep
$2
]
}
{
"SBC-R,R"
[
[
$1
]
keep
[
$3
]
keep
[
sub-byte-with-carry
]
keep
$2
]
}
{
"ADD-R,R"
[
[
$1
]
keep
[
$3
]
keep
[
add-byte
]
keep
$2
]
}
{
"LD-RR,(NN)"
[
[
next-word
]
keep
[
read-word
]
keep
$2
]
}
{
"IN-R,(N)"
[
[
next-byte
]
keep
[
read-port
]
keep
a<<
]
}
{
"SBC-R,N"
[
[
$1
]
keep
[
next-byte
]
keep
[
sub-byte-with-carry
]
keep
$2
]
}
{
"ADD-R,N"
[
[
$1
]
keep
[
next-byte
]
keep
[
add-byte
]
keep
$2
]
}
{
"DAA"
[
(emulate-DAA)
]
}
{
"LD-R,N"
[
[
next-byte
]
keep
$2
]
}
{
"DEC-(RR)"
[
[
$1
]
keep
[
read-byte
]
keep
[
dec-byte
]
keep
[
$1
]
keep
write-byte
]
}
{
"CP-R"
[
[
a>>
]
keep
[
$1
]
keep
sub-byte
drop
]
}
{
"LD-R,R"
[
[
$3
]
keep
$2
]
}
{
"CP-N"
[
[
a>>
]
keep
[
next-byte
]
keep
sub-byte
drop
]
}
{
"XOR-(RR)"
[
[
a>>
]
keep
[
$1
]
keep
[
read-byte
]
keep
[
xor-byte
]
keep
a<<
]
}
{
"CALL-F|FF,NN"
[
[
$1
]
1check
[
7
over
inc-cycles
(emulate-CALL)
]
[
[
pc>>
2
+
]
keep
pc<<
]
if
]
}
{
"INC-RR"
[
[
$1
]
keep
[
inc-word
]
keep
$2
]
}
{
"RST-8"
[
8
swap
(emulate-RST)
]
}
{
"RST-30H"
[
48
swap
(emulate-RST)
]
}
{
"EI"
[
[
interrupt-flag
]
swap
cpu-f-bitor
]
}
{
"CALL-NN"
[
(emulate-CALL)
]
}
{
"SUB-(RR)"
[
[
a>>
]
keep
[
$1
]
keep
[
read-byte
]
keep
[
sub-byte
]
keep
a<<
]
}
{
"DEC-R"
[
[
$1
]
keep
[
dec-byte
]
keep
$2
]
}
{
"LD-RR,NN"
[
[
next-word
]
keep
$2
]
}
{
"RST-0"
[
0
swap
(emulate-RST)
]
}
{
"LD-(NN),R"
[
[
$1
]
keep
[
next-word
]
keep
write-byte
]
}
{
"HALT"
[
drop
]
}
{
"LD-RR,RR"
[
[
$3
]
keep
$2
]
}
{
"RET-NN"
[
ret-from-sub
]
}
{
"ADD-R,(RR)"
[
[
$1
]
keep
[
$3
]
keep
[
read-byte
]
keep
[
add-byte
]
keep
$2
]
}
{
"CPL"
[
(emulate-CPL)
]
}
{
"RLA"
[
(emulate-RLA)
]
}
{
"OUT-(N),R"
[
[
$1
]
keep
[
next-byte
]
keep
write-port
]
}
{
"SUB-N"
[
[
a>>
]
keep
[
next-byte
]
keep
[
sub-byte
]
keep
a<<
]
}
{
"JP-F|FF,NN"
[
[
$1
]
1check
[
[
next-word
]
keep
[
pc<<
]
keep
[
cycles>>
]
1check
5
+
swap
cycles<<
]
[
[
pc>>
2
+
]
keep
pc<<
]
if
]
}
{
"SUB-R"
[
[
a>>
]
keep
[
$1
]
keep
[
sub-byte
]
keep
a<<
]
}
{
"EX-(RR),RR"
[
[
$1
]
keep
[
read-word
]
keep
[
$3
]
keep
[
$1
]
keep
[
write-word
]
keep
$4
]
}
{
"ADC-R,N"
[
[
$1
]
keep
[
next-byte
]
keep
[
add-byte-with-carry
]
keep
$2
]
}
{
"AND-R"
[
[
a>>
]
keep
[
$1
]
keep
[
and-byte
]
keep
a<<
]
}
{
"CP-(RR)"
[
[
a>>
]
keep
[
$1
]
keep
[
read-byte
]
keep
sub-byte
drop
]
}
{
"ADC-R,R"
[
[
$1
]
keep
[
$3
]
keep
[
add-byte-with-carry
]
keep
$2
]
}
{
"ADC-R,(RR)"
[
[
$1
]
keep
[
$3
]
keep
[
read-byte
]
keep
[
add-byte-with-carry
]
keep
$2
]
}
{
"AND-N"
[
[
a>>
]
keep
[
next-byte
]
keep
[
and-byte
]
keep
a<<
]
}
{
"RST-38H"
[
56
swap
(emulate-RST)
]
}
{
"RRCA"
[
(emulate-RRCA)
]
}
{
"CCF"
[
carry-flag
swap
cpu-f-bitxor=
]
}
{
"INC-R"
[
[
$1
]
keep
[
inc-byte
]
keep
$2
]
}
{
"LD-R,(RR)"
[
[
$3
]
keep
[
read-byte
]
keep
$2
]
}
{
"LD-R,(NN)"
[
[
next-word
]
keep
[
read-byte
]
keep
$2
]
}
{
"JP-NN"
[
[
pc>>
]
keep
[
read-word
]
keep
pc<<
]
}
}
;