Re: x86 VM
- Posted by "Darth Maul, aka Matt" <uglyfish87 at HOTMAIL.COM> Nov 11, 2000
- 472 views
Before I send it, you should know a little something about the VM's(86VM) innards. * The file vm_codes.e is included, and each opcode is registered(opcodes can be 1 to 2 bytes long). * 86VM loads the program into VM memory so the program may read any data in the file. * 86VM reads in a .COM file(.EXEs and files above 64K are not allowed), gets a character, looks for it in the x86 opcode table. If it's found, it reads another character and checks all the 2-byte codes in the opcode table. If a corresponding 2-byte code is not found, it's obviously 1 byte. * If the opcode has been identified, it adds the corresponding routine ID, the parameters(as defined in the sequence 'read_param_method')(each parameter may be a byte or word), and the size of the x86 opcode and its arguments. The position in the file and in the code sequence is stored in a sequence called 'IP' * If not, it immediately stops processing opcodes. * When it's done processing, the IP register is read(it starts at 0). 86VM will read IP, and it searches for it in IP[x][1]. If it is found, it a variable called x to 1. If it is not found, 86VM bombs out with an error. Otherwise, the opcode's routine ID is executed and set to the position in the file it found. When JMP NEAR and JMP SHORT execute, they get the current memory location of the current IP and convert the parameter into a signed offset. Then, the offset is added to the IP, it makes an index from the code sequence, and sets the IP. Just about every .COM program ever written would work perfectly if these near and short jumps would work! P.S. Far jumps trigger a segment violation because segments haven't been implemented yet. In fact, I'm thinking about creating another VM(86VM- based of course) for some non-existent 32-bit segmentless platform.