-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_opcodes.go
More file actions
68 lines (66 loc) · 2.27 KB
/
basic_opcodes.go
File metadata and controls
68 lines (66 loc) · 2.27 KB
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
package dcpu
type BasicOpcode uint16
// Basic opcodes.
const (
// BasicReserved indicates to use a special instruction.
BasicReserved = iota
// Set sets b to a.
Set
// Add sets b to b + a, sets EX to 0x1 upon overflow or 0x0 otherwise.
Add
// Subtract sets b to b - a, sets EX to 0xffff upon underflow or 0x0 otherwise.
Subtract
// Multiply sets b to b * a, sets EX to ((b * a) >> 16) & 0xffff treating a and b as unsigned.
Multiply
// MultiplySigned is like Multiply, but treats a and b as signed.
MultiplySigned
// Divide sets b to b / a, sets EX to ((b << 16) / a) & 0xffff. If a is 0, sets b and EX to 0 instead.
// Treats a and b as unsigned.
Divide
// DivideSigned is like Divide, but treats a and b as signed.
DivideSigned
// Modulo sets b to b % a. If a is 0, sets b to 0 instead.
Modulo
// ModuloSigned is like Modulo, but treats a and b as signed.
ModuloSigned
// BinaryAnd sets b to b & a.
BinaryAnd
// BinaryOr sets b to b | a.
BinaryOr
// BinaryExclusiveOr sets b to b ^ a.
BinaryExclusiveOr
// ShiftRight sets b to b >>> a, sets EX to ((b << 16) >> a) & 0xffff.
ShiftRight
// ArithmeticShiftRight sets b to b >> a, sets EX to ((b << 16) >>> a) & 0xffff. Treats b as signed.
ArithmeticShiftRight
// ShiftLeft sets b to b << a, sets EX to ((b << a) >> 16) & 0xffff.
ShiftLeft
// IfBitSet performs the next instruction only if b & a is not 0.
IfBitSet
// IfClear performs the next instruction only if b & a is 0.
IfClear
// IfEqual performs the next instruction only if b == a.
IfEqual
// IfNotEqual performs the next instruction only if b != a.
IfNotEqual
// IfGreaterThan performs the next instruction only if b > a.
IfGreaterThan
// IfAbove performs the next instruction only if b > a, signed.
IfAbove
// IfLessThan performs the next instruction only if b < a.
IfLessThan
// IfUnder performs the next instruction only if b < a, signed.
IfUnder
_
_
// AddWithCarry sets b to b + a + EX, sets EX to 0x1 upon overflow or 0x0 otherwise.
AddWithCarry
// SubtractWithCarry sets b to b - a + EX, sets EX to 0xffff upon underflow, 0x1 upon overflow or 0x0 otherwise.
SubtractWithCarry
_
_
// SetThenIncrement sets b to a, then increments I and J by one.
SetThenIncrement
// SetThenDecrement sets b to a, then decrements I and J by one.
SetThenDecrement
)