Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vm_2015
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Bay
vm_2015
Commits
97fbd1d0
Commit
97fbd1d0
authored
Nov 17, 2015
by
Christian Bay
Browse files
Options
Downloads
Patches
Plain Diff
CPU: Store each jump inst in file with and without extension byte
parent
314db2d2
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
vm/comp/cpu.c
+12
-4
12 additions, 4 deletions
vm/comp/cpu.c
vm/comp/cpu_JumpInst.c
+25
-0
25 additions, 0 deletions
vm/comp/cpu_JumpInst.c
vm/comp/cpu_extInst.c
+24
-0
24 additions, 0 deletions
vm/comp/cpu_extInst.c
with
61 additions
and
4 deletions
vm/comp/cpu.c
+
12
−
4
View file @
97fbd1d0
...
...
@@ -663,9 +663,6 @@ cpu_step(void *_cpu_state) {
uint8_t
eight_bit_src
;
uint32_t
four_byte_src
;
/* Save old eip */
uint32_t
eip_old
=
cpu_state
->
eip
;
/* read the first byte from instruction pointer and increment ip
* afterards */
op_code
=
cpu_read_byte_from_ram
(
cpu_state
);
...
...
@@ -678,7 +675,16 @@ cpu_step(void *_cpu_state) {
#include
"cpu_cmpInst.c"
#include
"cpu_JbInst.c"
#include
"cpu_JumpInst.c"
case
0x0f
:
{
/* The opcode is two bytes long */
uint8_t
op_code_2
=
cpu_read_byte_from_ram
(
cpu_state
);
switch
(
op_code_2
){
#include
"cpu_extInst.c"
}
}
default:
break
;
...
...
@@ -686,6 +692,8 @@ cpu_step(void *_cpu_state) {
return
false
;
}
/** @brief nop - cpu does not support reading via bus
*/
static
bool
...
...
This diff is collapsed.
Click to expand it.
vm/comp/cpu_J
b
Inst.c
→
vm/comp/cpu_J
ump
Inst.c
+
25
−
0
View file @
97fbd1d0
...
...
@@ -5,21 +5,21 @@ case 0x72: {
int8_t
offset
=
cpu_read_byte_from_ram
(
cpu_state
);
if
(
cpu_get_carry_flag
(
cpu_state
)){
cpu_set_eip
(
cpu_state
,
eip_old
+
offset
);
cpu_set_eip
(
cpu_state
,
cpu_state
->
eip
+
offset
);
}
return
true
;
}
case
0x82
:
{
/* JB rel32
* Jump short if below (CF=1).
case
0x75
:
{
/* JNE rel8
* Jump short if not equal (ZF=0).
*/
int
32
_t
offset
=
cpu_read_
word
_from_ram
(
cpu_state
);
int
8
_t
offset
=
cpu_read_
byte
_from_ram
(
cpu_state
);
if
(
cpu_get_
carry
_flag
(
cpu_state
)){
cpu_set_eip
(
cpu_state
,
eip_old
+
offset
);
if
(
!
cpu_get_
zero
_flag
(
cpu_state
)){
cpu_set_eip
(
cpu_state
,
cpu_state
->
eip
+
offset
);
}
return
true
;
}
This diff is collapsed.
Click to expand it.
vm/comp/cpu_extInst.c
0 → 100644
+
24
−
0
View file @
97fbd1d0
case
0x82
:
{
/* JB rel32
* Jump short if below (CF=1).
*/
int32_t
offset
=
cpu_read_word_from_ram
(
cpu_state
);
if
(
cpu_get_carry_flag
(
cpu_state
)){
cpu_set_eip
(
cpu_state
,
cpu_state
->
eip
+
offset
);
}
return
true
;
}
case
0x85
:
{
/* JNE rel32
* Jump short if not equal (ZF=0).
*/
int32_t
offset
=
cpu_read_word_from_ram
(
cpu_state
);
if
(
!
cpu_get_zero_flag
(
cpu_state
)){
cpu_set_eip
(
cpu_state
,
cpu_state
->
eip
+
offset
);
}
return
true
;
}
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