document CPUID, with one puzzling exception

This commit is contained in:
Dan Luu 2013-03-19 15:09:51 -04:00
parent b52e4ead18
commit 7df7cedbf1
2 changed files with 10 additions and 8 deletions

View File

@ -4862,21 +4862,21 @@ CPU_X86.prototype.exec_internal = function(N_cycles, interrupt) {
_op = 24; _op = 24;
} }
function op_CPUID() { function op_CPUID() {
var Rb; var eax;
Rb = regs[0]; eax = regs[0];
switch (Rb) { switch (eax) {
case 0: case 0: // eax == 0: vendor ID
regs[0] = 1; regs[0] = 1;
regs[3] = 0x756e6547 & -1; regs[3] = 0x756e6547 & -1;
regs[2] = 0x49656e69 & -1; regs[2] = 0x49656e69 & -1;
regs[1] = 0x6c65746e & -1; regs[1] = 0x6c65746e & -1;
break; break;
case 1: case 1: // eax == 1: processor info and feature flags
default: default:
regs[0] = (5 << 8) | (4 << 4) | 3; regs[0] = (5 << 8) | (4 << 4) | 3; // family | model | stepping
regs[3] = 8 << 8; regs[3] = 8 << 8; // danluu: This is a mystery to me. This bit now indicates clflush line size, but must have meant something else in the past.
regs[1] = 0; regs[1] = 0;
regs[2] = (1 << 4); regs[2] = (1 << 4); // rdtsc support
break; break;
} }
} }

View File

@ -25,6 +25,8 @@ have been added.
The core opcode execution loop has been autocommented to indicate what The core opcode execution loop has been autocommented to indicate what
instruction operation the opcode refers to. instruction operation the opcode refers to.
One mystery is, why does CPUID(1) return 8 << 8 in EBX? EBX[15:8] is now used to indicate CLFLUSH line size, but that field must have been used for something else in the past.
### ETC ### ETC
I highly recommend, by the way, the excellent [JSShaper][2] library for transforming large javascript code bases. The hacks I made from it are in this repo: a little symbol-name-transformer node.js script and an emacs function for doing this in live buffers. I highly recommend, by the way, the excellent [JSShaper][2] library for transforming large javascript code bases. The hacks I made from it are in this repo: a little symbol-name-transformer node.js script and an emacs function for doing this in live buffers.