-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadStore.cs
99 lines (90 loc) · 3.36 KB
/
LoadStore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace armsimGUI
{
/// <summary>
/// Class: LdStore
/// Inherits: Instruction
/// Purpose: Contains logic to load each of the Load/Store properties corresponding with
/// a Load/Store instruction
/// Methods: LdStore(uint)
/// LoadP()
/// LoadU()
/// LoadB()
/// LoadW()
/// LoadL()
/// LoadImmediateInt()
/// </summary>
public class LdStore : Instruction
{
public bool P { get; private set; } // P bit
public bool U { get; private set; } // U bit
public bool B { get; private set; } // B bit
public bool W { get; private set; } // W bit
public bool L { get; private set; } // L bit
public uint immediateVal { get; private set; } // value of immediate data
public LdStore(uint data)
{
instructionData = data;
isBranch = false;
}
public override void ExecuteInstruction(bool generateDisasm)
{
bool bit20 = Instruction.TestBit(this.instructionData, 20); // test bit 20
if (bit20) ops.LDR(this, generateDisasm);
else ops.STR(this, generateDisasm);
}
#region Internal Members
//--------------------------------------------------------------
// Purpose: Loads the P property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadP()
{
P = Memory.TestFlagInData(instructionData, 24);
}
//--------------------------------------------------------------
// Purpose: Loads the B property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadB()
{
B = Memory.TestFlagInData(instructionData, 22);
}
//--------------------------------------------------------------
// Purpose: Loads the L property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadL()
{
L = Memory.TestFlagInData(instructionData, 20);
}
//--------------------------------------------------------------
// Purpose: Loads the U property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadU()
{
U = Memory.TestFlagInData(instructionData, 23);
}
//--------------------------------------------------------------
// Purpose: Loads the W property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadW()
{
W = Memory.TestFlagInData(instructionData, 21);
}
//--------------------------------------------------------------
// Purpose: Loads the immediateVal property
// Returns: nothing
//--------------------------------------------------------------
internal override void LoadImmediateInt()
{
immediateVal = Memory.ExtractBits(instructionData, 0, 11);
}
#endregion
}
}