@@ -18,30 +18,21 @@ var registers, buffer [32]int64
18
18
19
19
var flagNegative , flagZero , flagOverflow , flagCarry bool
20
20
21
- /*
22
- * method to initiate register values
23
- */
24
-
21
+ // method to initiate register values.
25
22
func InitRegisters () {
26
23
registers [XZR ] = 0
27
24
registers [SP ] = MEMORY_SIZE * 4
28
25
}
29
26
30
- /*
31
- * function to store register values in a buffer
32
- */
33
-
27
+ // function to store register values in a buffer.
34
28
func SaveRegisters () {
35
29
var i int
36
30
for i = 0 ; i < 32 ; i ++ {
37
31
buffer [i ] = registers [i ]
38
32
}
39
33
}
40
34
41
- /*
42
- * function to show register values
43
- */
44
-
35
+ // function to pretty print register values to terminal.
45
36
func ShowRegisters (showAll bool ) {
46
37
var i int
47
38
var hasUpdated bool = false
@@ -79,41 +70,29 @@ func ShowRegisters(showAll bool) {
79
70
}
80
71
}
81
72
82
- /*
83
- * Method to read data from memory
84
- * Guarantees mutually exclusive access
85
- */
86
-
73
+ // Method to read data from memory.
74
+ // Guarantees mutually exclusive access.
87
75
func (dataMemory * DataMemory ) read (address uint64 ) int32 {
88
76
dataMemory .RLock ()
89
77
value := dataMemory .Memory [address ]
90
78
dataMemory .RUnlock ()
91
79
return value
92
80
}
93
81
94
- /*
95
- * Method to write data to memory
96
- * Guarantees mutually exclusive access
97
- */
98
-
82
+ // Method to write data to memory.
83
+ // Guarantees mutually exclusive access.
99
84
func (dataMemory * DataMemory ) write (address uint64 , value int32 ) {
100
85
dataMemory .Lock ()
101
86
dataMemory .Memory [address ] = value
102
87
dataMemory .Unlock ()
103
88
}
104
89
105
- /*
106
- * Function to read from register
107
- */
108
-
90
+ // Function to read from register and return its value.
109
91
func getRegisterValue (registerIndex uint ) int64 {
110
92
return registers [registerIndex ]
111
93
}
112
94
113
- /*
114
- * Function to write to register
115
- */
116
-
95
+ // Function to write to register.
117
96
func setRegisterValue (registerIndex uint , value int64 ) {
118
97
registers [registerIndex ] = value
119
98
}
0 commit comments