Open a console window with my VM

Hello. I am trying to teach myself more about how computers work on a very low level by taking a more practical path, I am writing my own simplistic virtual machine, that reads a simple machine code that I have devised (similar to Java bytecode) and I was wondering how other machine codes like x86 assembly language for example, tell Windows to open a console application for example, when all their instructions just do things like arithmetic, logic, allocating memory etc. This may seem like a stupid question, but I dont really know much about this sort of thing, so if anyone can enlighten be I would be very grateful. I'm not asking for any code examples or something, just a description on how its done. Thankyou.
You communicate with Windows by calling functions of the WinAPI. Those functions are in DLLs that are loaded into the address space of a process when the program is started, allowing you to call them using call/jmp instructions.
As for how those functions do it: x86 can do more than logic and arithmetic, in particular it can talk to hardware using the in/out instructions, which allows communicating with the graphics card, among other devices.
Owain, you kind of have it backwards. x86 doesn't tell Windows what do do, Windows tells the processor what to do using x86 opcodes. Your program will tell Windows what to do before that by calling functions in the WinAPI.
Oh okay, I understand. This means I will have to extend my machine language somewhat, because it only contains instructions for memory control, logic, arithmetic, control transfer, type conversion and stack control (because it is a stack-oriented language). Thanks for replying :)
Last edited on
Topic archived. No new replies allowed.