Skip to content

Commit

Permalink
flags highlighted purple when used
Browse files Browse the repository at this point in the history
  • Loading branch information
AdinAck committed Dec 1, 2022
1 parent aea9fa2 commit 589411e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 0 additions & 2 deletions LEGv8-Simulator/Models/CPUModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ class CPUModel: ObservableObject, CustomStringConvertible {
return "Registers:\n\(reg)\nMemory:\n\(mem)\nFlags: \(flags)"
}

init() { }

public static func registerSort(lhs: String, rhs: String) -> Bool {
if lhs == "xzr" {
return false
Expand Down
12 changes: 12 additions & 0 deletions LEGv8-Simulator/Utils/Interpreter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Interpreter: ObservableObject {
@Published var lastTouchedMemory: Int64?
@Published var lastUsedRegisters: [String] = []
@Published var lastUsedMemory: Int64?
@Published var usedFlags: Bool = false

@Published var log: [LogEntry] = []
@Published var history: History = History()
Expand Down Expand Up @@ -292,6 +293,7 @@ class Interpreter: ObservableObject {
lastUsedRegisters = []
lastUsedMemory = nil
cpu.touchedFlags = false
usedFlags = false

if mode == .assembling {
// assembly
Expand Down Expand Up @@ -497,24 +499,34 @@ class Interpreter: ObservableObject {
b(arguments[0])
case "b.eq":
b_eq(arguments[0])
usedFlags = true
case "b.ne":
b_ne(arguments[0])
usedFlags = true
case "b.hs":
b_hs(arguments[0])
usedFlags = true
case "b.lo":
b_lo(arguments[0])
usedFlags = true
case "b.hi":
b_hi(arguments[0])
usedFlags = true
case "b.ls":
b_ls(arguments[0])
usedFlags = true
case "b.ge":
b_ge(arguments[0])
usedFlags = true
case "b.lt":
b_lt(arguments[0])
usedFlags = true
case "b.gt":
b_gt(arguments[0])
usedFlags = true
case "b.le":
b_le(arguments[0])
usedFlags = true
case "br":
br(arguments[0])
lastUsedRegisters = [arguments[0]]
Expand Down
2 changes: 1 addition & 1 deletion LEGv8-Simulator/Views/Registers/FlagView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct FlagView: View {
}
}
.frame(maxWidth: 300)
.background(RoundedRectangle(cornerRadius: 8).fill(interpreter.cpu.touchedFlags ? Color.blue : Color.black.opacity(0.2)))
.background(RoundedRectangle(cornerRadius: 8).fill(interpreter.cpu.touchedFlags ? Color.blue : interpreter.usedFlags ? Color.purple : Color.black.opacity(0.2)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion LEGv8-Simulator/Views/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

struct AboutView: View {
let version: String = "0.1.7 (Beta)"
let version: String = "0.1.8 (Beta)"

var body: some View {
HStack {
Expand Down

0 comments on commit 589411e

Please sign in to comment.