commit 9764c0d3186a99bb2c0e28068d057a43c6554aee
parent 5fba1092c3764d1f25e95a4543e3a39f32778390
Author: Andrew Laack <andrew@laack.co>
Date: Mon, 12 Oct 2026 19:37:21 -0500
Started working on simulator
Diffstat:
4 files changed, 13 insertions(+), 70 deletions(-)
diff --git a/perf-aware-programming/8086-ref/Makefile b/perf-aware-programming/8086-ref/Makefile
@@ -1,5 +1,5 @@
build:
- g++ sim.cpp -o simulate
+ g++ sim86.cpp -o simulate
run: build
./simulate source/listing_0043_immediate_movs
diff --git a/perf-aware-programming/8086-ref/sim.cpp b/perf-aware-programming/8086-ref/sim.cpp
@@ -1,52 +0,0 @@
-#include <stdint.h>
-
-#include "sim86.h"
-
-#include "sim86_memory.h"
-#include "sim86_text.h"
-#include "sim86_decode.h"
-
-#include "sim86_memory.cpp"
-#include "sim86_text.cpp"
-#include "sim86_decode.cpp"
-
-typedef struct {
- u32 index;
- u8 size;
-} Register;
-
-Register AX {0,2};
-Register AH {0,1};
-Register AL {1,1};
-
-Register BX {2,2};
-Register BH {2,1};
-Register BL {3,1};
-
-Register CX {4,2};
-Register CH {4,1};
-Register CL {5,1};
-
-Register DX {6,2};
-Register DH {6,1};
-Register DL {7,1};
-
-int main(int argc, char** argv) {
- // first 8 bytes are registers.
- unsigned char stateBuffer[1024*1024];
- u8 done = 0;
- FILE* fp = fopen(argv[1], "rb");
-
- if(fp == NULL) {
- return -1;
- }
-
- unsigned char buffer[65536];
-
- u32 n = fread(buffer, 1, sizeof(buffer), fp);
-
- for(u32 i = 0; i < n; ++i) {
- printf("%hhd", buffer[i]);
- }
- fclose(fp);
-}
diff --git a/perf-aware-programming/8086-ref/sim86.cpp b/perf-aware-programming/8086-ref/sim86.cpp
@@ -1,15 +1,3 @@
-/* ========================================================================
-
- (C) Copyright 2023 by Molly Rocket, Inc., All Rights Reserved.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Please see https://computerenhance.com for more information
-
- ======================================================================== */
-
#include "sim86.h"
#include "sim86_memory.h"
@@ -43,11 +31,18 @@ static void DisAsm8086(memory *Memory, u32 DisAsmByteCount, segmented_access Dis
}
UpdateContext(&Context, Instruction);
- if(IsPrintable(Instruction))
- {
- PrintInstruction(Instruction, stdout);
- printf("\n");
- }
+ printf("%s", GetMnemonic(Instruction.Op));
+ unsigned char before = 0x10;
+ unsigned char after = 12;
+ printf(" ; 0x%x->0x%x", before, after);
+ printf("\n");
+
+// if(IsPrintable(Instruction))
+ // {
+ // PrintInstruction(Instruction, stdout);
+
+ // }
+
}
else
{
diff --git a/perf-aware-programming/8086-ref/simulate b/perf-aware-programming/8086-ref/simulate
Binary files differ.