octarect / emu_x86 Goto Github PK
View Code? Open in Web Editor NEWThe x86 CPU emulator
The x86 CPU emulator
void set_register8(Emulator* emu, int index, uint8_t value)
{
if (index < 4) {
uint32_t r = emu->registers[index] & 0xffffff00;
emu->registers[index] = r | (uint32_t)value;
} else {
uint32_t r = emu->registers[index] & 0xffff00ff;
emu->registers[index - 4] = r | ((uint32_t)value << 8);
}
}
Fixed looks like this
void set_register8(Emulator* emu, int index, uint8_t value)
{
if (index < 4) {
uint32_t r = emu->registers[index] & 0xffffff00;
emu->registers[index] = r | (uint32_t)value;
} else {
uint32_t r = emu->registers[index - 4] & 0xffff00ff;
emu->registers[index - 4] = r | ((uint32_t)value << 8);
}
}
missing - 4 on the first registers array on the bottom of the else statement
Fixed also eval_sib(..)
function it was off.
new code looks like this
uint32_t eval_sib(Emulator* emu, ModRM* modrm) {
uint8_t sib = modrm->sib;
uint8_t scale = (sib >> 6) & 0x03; //((sib & 0xC0) >> 6); //old broken code
uint8_t base = sib & 0x07; //((sib & 0x38) >> 3); //old broken code
uint8_t index = (sib >> 3) & 0x07; //(sib & 0x03); //old broken code
Sib formula by this image match
7 6 5 4 3 2 1 0
+---+---+---+---+---+---+---+---+
| mod | reg | rm |
+---+---+---+---+---+---+---+---+
changed parse_modrm 16_32 into 1 and changed
modrm->mod = (code >> 6) & 0x03; //old code ((code & 0xC0) >> 6);
modrm->opcode = (code >> 3) & 0x07; //old code ((code & 0x38) >> 3);
modrm->rm = code & 0x07; //old code code & 0x07;
another bug where you see modrm->mod == 5
and modrm->mod == 6
you meant to use modrm->rm == 5
and modrm->rm == 6
because mod doesn't pass the value 3 it's only 2 bits.
http://download.intel.com/design/intarch/manuals/24319101.pdf Page 35 for 16 bit and page 36 for 32 bit.
I fixed more like lea_r16_m
made it lea_r16_r32_m
haha. added xor, or, and, stos, prefixes (buggy) still needs segments maybe? idk never worked with cpu emulators, others have it, maybe not needed.
update1: https://www.mediafire.com/?cg2q2lmfexbepz5
update2: http://www.mediafire.com/?7t601e27r348178
update3: http://www.mediafire.com/?8c3p50pp7zveo67
on update3 i fixed the memory issue.
I hope you not abandoned this project it's very good compared to other cpu emulators this is the simplest one which is best :)
it needs FPU support to be better then any other cpu emulator and still small and simple.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.