Hello,
for some reason I want to use the Virtual x86 Mode with NASM also in order to use the original BIOS Interrupts and Routines in a kind of Real-Mode simulated data aera.
I think this is quiet helpfull and instructive and it shouldn't be nessecary to use a so called DOS-BOX. I also don't want to use dosemu or as far as possible the kernel support with C-Headers or stuff like this.
I'd only like to know how i can manage to switch in that mode and than again back in PM on a - as far as possible - simple way. All I found on that topic until know was a generell description but not really a usefull example for me on how to do it directly. I think it is not very difficult to understand the generall idea. For example you can use an INT n instruction witch call the kernel running in privilege level 0. Before you use the IRET-Instruction to return to the caller you set the VM-Flag 17 in the image of eflag on the stack and have pushed the segment registers in Real Mode adressing too, and after you return to privilege 3 user level you should be in the Virtual Mode.
Theoretical this should be one of a least two ways to do it. But how can I get in an interrupt as an normal user? I mean, how can I put the right code in the Interrupts structure whithout having access to the inside of it? (If it is at all alloud and possible) Normally I call interrupts in linux whith only one line (int 080h) and that's it, waiting for the kernel to it's work and return by itself, if its ready, without any support of own programm code by myself.
Another problems seems to be how to mapp the original BIOS in the right data area and how to get it (perhaps with break?)
Above all can it be a problem that I've been working with an x86_64 arch?
Here are two links on that topic:
http://lowlevel.brainsware.org/wiki/index.php/Virtual_8086_Modehttp://osdev.berlios.de/v86.htmland here's a excerption of the Intel manual about the Virtual- 8086 Mode:
"15.2.1 Enabling Virtual-8086 Mode
The processor runs in virtual-8086 mode when the VM (virtual machine) flag in the
EFLAGS register is set. This flag can only be set when the processor switches to a
new protected-mode task or resumes virtual-8086 mode via an IRET instruction.
System software cannot change the state of the VM flag directly in the EFLAGS
register (for example, by using the POPFD instruction). Instead it changes the flag in
the image of the EFLAGS register stored in the TSS or on the stack following a call to
an interrupt- or exception-handler procedure. For example, software sets the VM flag
in the EFLAGS image in the TSS when first creating a virtual-8086 task.
The processor tests the VM flag under three general conditions:
• When loading segment registers, to determine whether to use 8086-style
address translation.
• When decoding instructions, to determine which instructions are not supported in
virtual-8086 mode and which instructions are sensitive to IOPL.
• When checking privileged instructions, on page accesses, or when performing
other permission checks. (Virtual-8086 mode always executes at CPL 3.)..."
Does anyone know a kind of realizeable way, a kind of scaffold, or template that shows how it really can be done? Perhaps it is possible in NASM without using C or more advanced concepts like dosemu is?
Thanks a lot for every answer in advane
Michel