Make more improvements

This change includes many bug fixes, for the NT polyfills, strings,
memory, boot, and math libraries which were discovered by adding more
tools for recreational programming, such as PC emulation. Lemon has also
been vendored because it works so well at parsing languages.
This commit is contained in:
Justine Tunney 2020-09-28 01:13:56 -07:00
parent 416fd86676
commit 23d333c090
201 changed files with 14558 additions and 3082 deletions

View file

@ -52,18 +52,33 @@ static void DecodeInstruction(struct Machine *m, uint8_t *p, unsigned n) {
}
}
static noinline void LoadInstructionSlow(struct Machine *m, uint64_t ip) {
unsigned i;
uint8_t *addr;
uint8_t copy[15], *toil;
i = 0x1000 - (ip & 0xfff);
addr = ResolveAddress(m, ip);
if ((toil = FindReal(m, ip + i))) {
memcpy(copy, addr, i);
memcpy(copy + i, toil, 15 - i);
DecodeInstruction(m, copy, 15);
} else {
DecodeInstruction(m, addr, i);
}
}
void LoadInstruction(struct Machine *m) {
uint64_t ip;
unsigned i, key;
uint8_t *addr, *toil, copy[15];
unsigned key;
uint8_t *addr;
ip = Read64(m->cs) + MaskAddress(m->mode & 3, m->ip);
key = ip & (ARRAYLEN(m->icache) - 1);
m->xedd = (struct XedDecodedInst *)m->icache[key];
if ((i = 0x1000 - (ip & 0xfff)) >= 15) {
if (ROUNDDOWN(ip, 0x1000) == m->codevirt && ip) {
if ((ip & 0xfff) < 0x1000 - 15) {
if (ip - (ip & 0xfff) == m->codevirt && ip) {
addr = m->codereal + (ip & 0xfff);
} else {
m->codevirt = ROUNDDOWN(ip, 0x1000);
m->codevirt = ip - (ip & 0xfff);
m->codereal = ResolveAddress(m, m->codevirt);
addr = m->codereal + (ip & 0xfff);
}
@ -71,13 +86,6 @@ void LoadInstruction(struct Machine *m) {
DecodeInstruction(m, addr, 15);
}
} else {
addr = ResolveAddress(m, ip);
if ((toil = FindReal(m, ip + i))) {
memcpy(copy, addr, i);
memcpy(copy + i, toil, 15 - i);
DecodeInstruction(m, copy, 15);
} else {
DecodeInstruction(m, addr, i);
}
LoadInstructionSlow(m, ip);
}
}