@@ -96,6 +98,7 @@ import { AddressingMode } from '../../utils/settings'
import { computed, onMounted, reactive, watch } from 'vue'
import { ArrowDownIcon, ArrowUpIcon } from '@heroicons/vue/24/solid'
+import NumberField from './NumberField.vue'
const targetRows = 32
const targetColumns = 8
@@ -116,6 +119,8 @@ function addressingModeSize(mode: AddressingMode) {
}
}
+const unitSize = computed(() => addressingModeSize(settings.memory.mode))
+
function setMode(event: Event) {
const input = event.target as HTMLInputElement
@@ -124,11 +129,38 @@ function setMode(event: Event) {
} catch {}
}
-function shift(bytes: number[]): string {
- let result = ''
+function setAddress(start: number, index: number, to: number, mode: AddressingMode) {
+ if (!consoleData.execution) {
+ return
+ }
+
+ const address = start + index * unitSize.value
+
+ switch (mode) {
+ case AddressingMode.Byte:
+ consoleData.execution.setMemory(address, [to])
+ break
+ case AddressingMode.Half:
+ consoleData.execution.setMemory(address, [to & 0xff, (to >> 8) & 0xff])
+ break
+ case AddressingMode.Word:
+ consoleData.execution.setMemory(address, [
+ to & 0xff,
+ (to >> 8) & 0xff,
+ (to >> 16) & 0xff,
+ (to >> 24) & 0xff,
+ ])
+ break
+ }
+}
+
+function shift(bytes: number[]): number {
+ let result = 0
- for (const byte of bytes) {
- result = byte.toString(16).padStart(2, '0') + result
+ for (const byte of bytes.reverse()) {
+ // Why not (result << 8) | byte?
+ // | and << give signed integers as the result, which isn't what I'm looking for.
+ result = (result * 256) + byte
}
return result
@@ -151,9 +183,7 @@ function addressString(value: number): string {
}
function pageSize() {
- const unitSize = addressingModeSize(settings.memory.mode)
-
- return targetRows * targetColumns * unitSize
+ return targetRows * targetColumns * unitSize.value
}
function moveAddress(direction: number) {
@@ -165,7 +195,8 @@ function moveAddress(direction: number) {
interface MemoryRow {
header: string
- items: string[]
+ address: number
+ items: number[]
}
interface MemoryTable {
@@ -182,29 +213,21 @@ const table = computed((): MemoryTable => {
header.push(`Value +${(column * unitSize).toString(16)}`)
}
- if (memory.data === null) {
+ const address = parseAddress(settings.memory.address)
+
+ if (memory.data === null || address === null) {
return {
header,
rows: null
}
}
- const address = parseAddress(settings.memory.address)
-
const data = memory.data
let index = 0
const result = [] as MemoryRow[]
for (let row = 0; row < targetRows; row++) {
- if (!address) {
- result.push({
- header: '',
- items: Array(targetColumns).fill(''),
- })
- continue
- }
-
if (index >= data.length) {
break
}
@@ -213,6 +236,7 @@ const table = computed((): MemoryTable => {
const element = {
header: addressString(start),
+ address: start,
items: [],
} as MemoryRow
diff --git a/src/components/console/NumberField.vue b/src/components/console/NumberField.vue
index b27b536..3cec935 100644
--- a/src/components/console/NumberField.vue
+++ b/src/components/console/NumberField.vue
@@ -34,12 +34,14 @@ const props = withDefaults(
checker?: (value: number) => string | null
editable?: boolean
cleanOnly?: boolean
+ bytes?: number
}>(),
{
hex: false,
classes: '',
editable: true,
cleanOnly: true,
+ bytes: 4,
}
)
@@ -93,7 +95,7 @@ function parse(leading: string): number | null {
const rest = text.substring(2)
// Validate
- if (!/^[0-9a-f]*$/.test(rest)) {
+ if (!/^[0-9a-fA-F]*$/.test(rest)) {
return null
}
@@ -111,10 +113,16 @@ function parse(leading: string): number | null {
result = 0x100000000 - result
}
+ result = result & (~0 >> ((4 - props.bytes) * 2))
+
return isNaN(result) ? null : result
}
function formatHex(value: number, hex: boolean): string {
+ if (props.bytes < 4) {
+ value = value & (0x7fffffff >> ((4 - props.bytes) * 8 - 1))
+ }
+
if (hex) {
const signed = Math.abs(value).toString(16)
diff --git a/src/utils/mips.ts b/src/utils/mips.ts
index 98b8aa5..11896f6 100644
--- a/src/utils/mips.ts
+++ b/src/utils/mips.ts
@@ -110,7 +110,7 @@ class Breakpoints {
public pcToGroup: Map
findNextPc(line: number): number[] {
- while (line < this.maxLine) {
+ while (line <= this.maxLine) {
const value = this.lineToPc.get(line)
if (value !== undefined) {
@@ -124,9 +124,11 @@ class Breakpoints {
}
public mapLines(lines: number[]): number[] {
- return lines
+ const x = lines
.flatMap((line) => this.findNextPc(line))
.filter((point) => !!point) as number[]
+
+ return x
}
// pc -> line
@@ -340,6 +342,10 @@ export class ExecutionState {
await tauri.invoke('set_register', { register, value })
}
+ public async setMemory(address: number, bytes: number[]) {
+ await tauri.invoke('write_bytes', { address, bytes })
+ }
+
public constructor(
public text: string,
public path: string | null,
From 25a9cbdcf0bb786c3a92f1b6227e1ac03960b99f Mon Sep 17 00:00:00 2001
From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com>
Date: Tue, 25 Jul 2023 23:16:38 -0700
Subject: [PATCH 07/31] Complete Memory Editing task in Readme
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c88c34c..f195a7a 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ yarn tauri build
# Important Tasks
-- [ ] Memory Editing and Copying
+- [x] Memory Editing and Copying
- [x] Register Editing and Copying
- [x] Finding Text (Cmd + F)
- [x] Finished Execution State
@@ -63,3 +63,4 @@ yarn tauri build
- [x] MIDI and Other Syscalls
- [x] Variable Name Suggestions
- [x] Improve Bitmap Display
+- [x] Add Time Travel
From f4717e445f3f8ee967f4a79e2dd4800598e0920c Mon Sep 17 00:00:00 2001
From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com>
Date: Thu, 27 Jul 2023 22:53:02 -0700
Subject: [PATCH 08/31] Change Debug tab items
---
src/components/console/Console.vue | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/components/console/Console.vue b/src/components/console/Console.vue
index 3d9c07a..5eaeb83 100644
--- a/src/components/console/Console.vue
+++ b/src/components/console/Console.vue
@@ -21,7 +21,7 @@
{{ modeString }}
@@ -57,12 +57,6 @@
@mousedown="() => (consoleData.tab = DebugTab.Bitmap)"
/>
-
-
-
-
-
-