/
leftshift.go
50 lines (41 loc) · 1.15 KB
/
leftshift.go
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
package isa
import (
"aletheiaware.com/flamego"
"fmt"
)
type LeftShift struct {
Source1Register flamego.Register
Source2Register flamego.Register
DestinationRegister flamego.Register
}
func NewLeftShift(s1, s2, d flamego.Register) *LeftShift {
return &LeftShift{
Source1Register: s1,
Source2Register: s2,
DestinationRegister: d,
}
}
func (i *LeftShift) Load(x flamego.Context) (uint64, uint64, uint64, uint64) {
// Load Source 1 Register
a := x.ReadRegister(i.Source1Register)
// Load Source 2 Register
b := x.ReadRegister(i.Source2Register)
return a, b, 0, 0
}
func (i *LeftShift) Execute(x flamego.Context, a, b, c, d uint64) (uint64, uint64) {
return a << b, 0
}
func (i *LeftShift) Format(x flamego.Context, a, b uint64) (uint64, uint64) {
return a, 0
}
func (i *LeftShift) Store(x flamego.Context, a, b uint64) {
// Write Destination Register
x.WriteRegister(i.DestinationRegister, a)
}
func (i *LeftShift) Retire(x flamego.Context) bool {
x.IncrementProgramCounter()
return true
}
func (i *LeftShift) String() string {
return fmt.Sprintf("leftshift %s %s %s", i.Source1Register, i.Source2Register, i.DestinationRegister)
}