Skip to content

Commit 779a986

Browse files
committed
Print table on at least one update
1 parent c5d963d commit 779a986

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Memory/DataMemory.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ func SaveRegisters() {
4444

4545
func ShowRegisters(showAll bool) {
4646
var i int
47+
var hasUpdated bool = false
4748
var registerNum, prevRegisterVal, newRegisterVal string
4849
table := tablewriter.NewWriter(os.Stdout)
4950
if showAll == true {
51+
hasUpdated = true
5052
table.SetHeader([]string{"Register", "Value"})
5153

5254
for i = 0; i < 32; i++ {
@@ -63,16 +65,18 @@ func ShowRegisters(showAll bool) {
6365

6466
for i = 0; i < 32; i++ {
6567
if getRegisterValue(uint(i)) != buffer[i] {
68+
hasUpdated = true
6669
registerNum = strconv.Itoa(i)
6770
prevRegisterVal = strconv.FormatInt(buffer[i], 10)
6871
newRegisterVal = strconv.FormatInt(getRegisterValue(uint(i)), 10)
6972
table.Append([]string{color.CyanString("R" + registerNum), color.RedString(prevRegisterVal), color.GreenString(newRegisterVal)})
7073
}
7174
}
7275
}
73-
74-
table.Render()
75-
fmt.Printf("\n")
76+
if hasUpdated {
77+
table.Render()
78+
fmt.Printf("\n")
79+
}
7680
}
7781

7882
/*

0 commit comments

Comments
 (0)