Skip to content

Commit 395293f

Browse files
committed
Add documentation as per GoDoc specs
1 parent f469728 commit 395293f

File tree

4 files changed

+285
-226
lines changed

4 files changed

+285
-226
lines changed

ALU/ALU.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
package ALU
22

3-
/*
4-
* Function to perform signed addition
5-
*/
3+
//Function to perform signed addition of two int64 numbers.
64
func Adder(val1, val2 int64) int64 {
75
return val1 + val2
86
}
97

10-
/*
11-
* Function to perform logical AND operation
12-
*/
138

9+
//Function to perform logical AND operation of two int64 numbers.
1410
func LogicalAND(val1, val2 int64) int64 {
1511
return val1 & val2
1612
}
1713

18-
/*
19-
* Function to perform logical OR operation
20-
*/
2114

15+
//Function to perform logical OR operation of two int64 numbers.
2216
func LogicalOR(val1, val2 int64) int64 {
2317
return val1 | val2
2418
}
2519

26-
/*
27-
* Function to perform logical XOR operation
28-
*/
2920

21+
//Function to perform logical XOR operation of two int64 numbers.
3022
func LogicalXOR(val1, val2 int64) int64 {
3123
return val1 ^ val2
3224
}
3325

34-
/*
35-
* Function to perform unsigned addition
36-
* Used only for setting Carry flag
37-
*/
26+
27+
//Function to perform unsigned addition of two uint64 numbers.
28+
//Used only for setting Carry flag.
3829
func UnsignedAdder(val1, val2 uint64) uint64 {
3930
return val1 + val2
4031
}

Memory/DataMemory.go

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,21 @@ var registers, buffer [32]int64
1818

1919
var flagNegative, flagZero, flagOverflow, flagCarry bool
2020

21-
/*
22-
* method to initiate register values
23-
*/
24-
21+
// method to initiate register values.
2522
func InitRegisters() {
2623
registers[XZR] = 0
2724
registers[SP] = MEMORY_SIZE * 4
2825
}
2926

30-
/*
31-
* function to store register values in a buffer
32-
*/
33-
27+
// function to store register values in a buffer.
3428
func SaveRegisters() {
3529
var i int
3630
for i = 0; i < 32; i++ {
3731
buffer[i] = registers[i]
3832
}
3933
}
4034

41-
/*
42-
* function to show register values
43-
*/
44-
35+
// function to pretty print register values to terminal.
4536
func ShowRegisters(showAll bool) {
4637
var i int
4738
var hasUpdated bool = false
@@ -79,41 +70,29 @@ func ShowRegisters(showAll bool) {
7970
}
8071
}
8172

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.
8775
func (dataMemory *DataMemory) read(address uint64) int32 {
8876
dataMemory.RLock()
8977
value := dataMemory.Memory[address]
9078
dataMemory.RUnlock()
9179
return value
9280
}
9381

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.
9984
func (dataMemory *DataMemory) write(address uint64, value int32) {
10085
dataMemory.Lock()
10186
dataMemory.Memory[address] = value
10287
dataMemory.Unlock()
10388
}
10489

105-
/*
106-
* Function to read from register
107-
*/
108-
90+
// Function to read from register and return its value.
10991
func getRegisterValue(registerIndex uint) int64 {
11092
return registers[registerIndex]
11193
}
11294

113-
/*
114-
* Function to write to register
115-
*/
116-
95+
// Function to write to register.
11796
func setRegisterValue(registerIndex uint, value int64) {
11897
registers[registerIndex] = value
11998
}

0 commit comments

Comments
 (0)