Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
30e2a631
Verified
Commit
30e2a631
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: add more instructions
parent
368bd1cd
No related branches found
No related tags found
No related merge requests found
Pipeline
#857
passed
2 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/inst.rs
+21
-12
21 additions, 12 deletions
src/inst.rs
with
21 additions
and
12 deletions
src/inst.rs
+
21
−
12
View file @
30e2a631
...
...
@@ -28,7 +28,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
ld_d_u8
,
8
,
"LD D, u8"
),
(
rla
,
4
,
"RLA"
),
(
jr_i8
,
12
,
"JR i8"
),
(
noimpl
,
4
,
"
! UNIMP !
"
),
(
add_hl_de
,
8
,
"
ADD HL, DE
"
),
(
ld_a_mde
,
8
,
"LD A, [DE]"
),
(
dec_de
,
8
,
"DEC DE"
),
(
inc_e
,
4
,
"INC E"
),
...
...
@@ -226,7 +226,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
ret_nc
,
8
,
"RET NC"
),
(
pop_de
,
12
,
"POP DE"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
push_de
,
16
,
"PUSH DE"
),
(
sub_a_u8
,
8
,
"SUB A, u8"
),
...
...
@@ -234,26 +234,26 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
noimpl
,
4
,
"! UNIMP !"
),
(
reti
,
16
,
"RETI"
),
(
jp_c_u16
,
12
,
"JP C, u16"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
call_c_u16
,
12
,
"CALL C, u16"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
// 0xe opcodes
(
ld_mff00u8_a
,
12
,
"LD [FF00+u8], A"
),
(
pop_hl
,
12
,
"POP HL"
),
(
ld_mff00c_a
,
8
,
"LD [FF00+C], A"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
push_hl
,
16
,
"PUSH HL"
),
(
and_a_u8
,
8
,
"AND A, u8"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
ld_mu16_a
,
16
,
"LD [u16], A"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
xor_a_u8
,
8
,
"XOR A, u8"
),
(
rst_18h
,
16
,
"RST 18h"
),
// 0xf opcodes
...
...
@@ -261,7 +261,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
pop_af
,
12
,
"POP AF"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
di
,
4
,
"DI"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
push_af
,
16
,
"PUSH AF"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
...
...
@@ -269,8 +269,8 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
noimpl
,
4
,
"! UNIMP !"
),
(
ld_a_mu16
,
16
,
"LD A [u16]"
),
(
ei
,
4
,
"EI"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
illega
l
,
4
,
"
ILLEGAL
"
),
(
cp_a_u8
,
8
,
"CP A, u8"
),
(
rst_38h
,
16
,
"RST 38h"
),
];
...
...
@@ -556,6 +556,10 @@ fn noimpl(_cpu: &mut Cpu) {
todo!
(
"Instruction not implemented"
);
}
fn
illegal
(
_cpu
:
&
mut
Cpu
)
{
panic!
(
"Illegal instruction"
);
}
fn
ld_bc_u16
(
cpu
:
&
mut
Cpu
)
{
let
word
=
cpu
.read_u16
();
cpu
.set_bc
(
word
);
...
...
@@ -708,6 +712,11 @@ fn jr_i8(cpu: &mut Cpu) {
cpu
.pc
=
(
cpu
.pc
as
i16
)
.wrapping_add
(
byte
as
i16
)
as
u16
;
}
fn
add_hl_de
(
cpu
:
&
mut
Cpu
)
{
let
value
=
add_u16_u16
(
cpu
,
cpu
.hl
(),
cpu
.de
());
cpu
.set_hl
(
value
);
}
fn
ld_a_mde
(
cpu
:
&
mut
Cpu
)
{
let
byte
=
cpu
.mmu
.read
(
cpu
.de
());
cpu
.a
=
byte
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment