summaryrefslogtreecommitdiff
path: root/src/msp430_instruction
blob: dfd297d2f9eaa6b5456c1033c2ef5823fa0266ea (plain)
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
byteOpFlag: bit{1}

RRC := b000
SWPB:= b001
RRA := b010
SXT := b011
PUSH:= b100
CALL:= b101
RETI:= b110

oneOpCode: bit{3} :=
  RRC | SWPB | RRA | SXT | PUSH | CALL | RETI

JNE := b000
JEQ := b001
JNC := b010
JC  := b011
JN  := b100
JGE := b101
JL  := b110
JMP := b111

jumpCondition: bit{3} :=
  JNE | JEQ | JNC | JC | JN | JGE | JL | JMP

MOV := b0100
ADD := b0101
ADDC:= b0110
SUBC:= b0111
SUB := b1000
CMP := b1001
DADD:= b1010
BIT := b1011
BIC := b1100
BIS := b1101
XOR := b1110
AND := b1111

twoOpCode: bit{4} :=
  MOV | ADD | ADDC | SUBC | SUB | CMP | DADD | BIT | BIC | BIS | XOR | AND

Symbolic := b1
Absolute := b1
RegisterDirect := b0
Indexed := b1

twoOpDestMode: bit{1} :=
  RegisterDirect | Indexed | Absolute | Symbolic

NextWord := b11
Const0 := b00
Const1 := b01
Const2 := b10
Const4 := b10
Const8 := b11
ConstNeg1 := b11
RegisterDirect := b00
Indexed := b01
RegisterIndirect := b10
IndirectAutoInc := b11

twoOpSourceMode: bit{2} :=
  NextWord | Const0 | Const1 |
  Const2 | Const4 | Const8 |
  ConstNeg1 | RegisterDirect | Indexed |
  RegisterIndirect | IndirectAutoInc

oneOpDestMode: bit{2} := twoOpSourceMode

sourceReg: bit{4}
destReg: bit{4} := sourceReg

noOp := b001:jumpCondition:pcOffset
oneOp := b000100:oneOpCode:byteOpFlag:oneOpDestMode:destReg
twoOp := twoOpCode:sourceReg:twoOpDestMode:byteOpFlag:twoOpSourceMode:destReg

root := oneOp | twoOp | noOp