diff --git a/src/components/Memory.vue b/src/components/Memory.vue index 2e439d1..0bb5ea1 100644 --- a/src/components/Memory.vue +++ b/src/components/Memory.vue @@ -12,8 +12,7 @@ const fileSelector = ref(null); const uploadDataDisabled = ref(true); -const loadAddressLowByte = ref('00'); -const loadAddressHighByte = ref('00'); +const loadAddress = ref('0000'); async function uploadData() { const suffix = file.value?.name.substring(file.value?.name.length - 4) || '.bin'; @@ -35,13 +34,12 @@ async function uploadData() { if (fileSelector.value) { fileSelector.value.value = ''; uploadDataDisabled.value = true; - loadAddressHighByte.value = '00'; - loadAddressLowByte.value = '00'; + loadAddress.value = '0000'; } } function importBinData(value: Uint8Array) { - comp.value.cpu.pc.setAsHexString(loadAddressLowByte.value, loadAddressHighByte.value); + comp.value.cpu.pc.setAsHexString(loadAddress.value.substring(2, 4), loadAddress.value.substring(0, 2)); // value comes in chunks of 65536 value.forEach((element, index) => { comp.value.mem.setInt(comp.value.cpu.pc.int + index, element); @@ -81,7 +79,7 @@ function onMemInputChanged($event: Event) { } } -function onHexInputChanged($event: Event) { +function onHex2InputChanged($event: Event) { const target = $event.target as HTMLInputElement; if (target) { @@ -90,6 +88,15 @@ function onHexInputChanged($event: Event) { } } +function onHex4InputChanged($event: Event) { + const target = $event.target as HTMLInputElement; + + if (target) { + target.value = (parseInt(target.value, 16) % 65536).toString(16).toUpperCase().padStart(4, '0'); + if (target.value === '0NAN') target.value = '0000'; + } +} + function addressToHex(value: number) { return value.toString(16).toUpperCase().padStart(4, '0'); } @@ -106,6 +113,10 @@ function setMemPageIndexToPcPage() { memPageIndex.value = comp.value.cpu.pc.getHighByte(); } +function clearMemory() { + comp.value.mem.reset(); +} + const memPage = computed(() => { const tmpMemPage: string[] = []; @@ -167,26 +178,20 @@ function getMemRowAsString(memPage: string[], index: number) {
+
- Load *.bin file at memory address - H - - L + Memory address of *.bin file loaded at
@@ -196,7 +201,7 @@ function getMemRowAsString(memPage: string[], index: number) { Memory Page - +
diff --git a/src/components/Registers.vue b/src/components/Registers.vue index 9de481f..f9aebeb 100644 --- a/src/components/Registers.vue +++ b/src/components/Registers.vue @@ -28,7 +28,7 @@ function onRegInputChanged($event: Event) { if (target && target.dataset.register === 'PC') { target.value = (parseInt(target.value, 16) % 65536).toString(16).toUpperCase().padStart(4, '0'); - if (target.value === 'NAN') target.value = '00'; + if (target.value === '0NAN') target.value = '0000'; } else { target.value = (parseInt(target.value, 16) % 256).toString(16).toUpperCase().padStart(2, '0'); if (target.value === 'NAN') target.value = '00';