Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hi, i was wondering how could i call interrupt in protected mode.
So i tried to switch to real mode, execute interrupt, and switch back to protected mode.
Well i use MS VS 2010 Ultimate C++ compiler and i got error "C2415: improper operand type".
This is what i do:
void intupt(char intr) // Call interrupt function, INTR is number of interrupt
{
pm2rm(); //Protected Mode to Real Mode
__asm
{
mov al, [intr] //Put INTR to register AL
int al // Call interrupt using register AL
}
rm2pm(); //Real Mode to Protected Mode
}
Please help me since i placed release date to tommorow !
How to fix this?
Last edited by Ycep on Thu May 19, 2016 1:04 pm, edited 1 time in total.
I don't think that is a legal instruction, you are also overwriting your ax/eax value before the interrupt. You might be able to define some asm data bytes like
lukaandjelkovic wrote:Please help me since i placed release date to tommorow
In SudoBIOS the interrupt number is a stack parameter used to index a copy of the original real mode IDT entry which is saved in a
global variable which is then used as an indirect call (after pushing the flags) to simulate an int instruction.
lukaandjelkovic wrote:Hi, i was wondering how could i call interrupt in protected mode.
So i tried to switch to real mode, execute interrupt, and switch back to protected mode.
Well i use MS VS 2010 Ultimate C++ compiler and i got error "C2415: improper operand type".
This is what i do:
void intupt(char intr) // Call interrupt function, INTR is number of interrupt
{
pm2rm(); //Protected Mode to Real Mode
__asm
{
mov al, [intr] //Put INTR to register AL
int al // Call interrupt using register AL
}
rm2pm(); //Real Mode to Protected Mode
}
Please help me since i placed release date to tommorow !
How to fix this?
You must be trying to dynamically call interrupts from a routine given the interrupt number.
The best way to do it is to keep your routine that calls interrupts, then you must perform exactly the actions that the INT instruction performs, and Calculate the Address of the Interrupt Vector and do a Manual Far Call or a Manual Far Jump to that address.
Instead of modifying the opcode of the INT instruction, just emulate that instruction.
Then you can call that interrupt manually given the register with the INT number you want to use.
However, try to use the stack or reload the register you want to use with the value the actual Interrupt Service expects, once you calculate the far address, or you will get in the way of the parameters for the actual interrupts and it will sill be a bad, dirty implementation to fix for tomorrow.
________________________
If you try to implement self-modifying code, it will surely become unstable and will just not last in your project (it will be deleted after proving that it is unstable).
lukaandjelkovic wrote:Please help me since i placed release date to tommorow !
Oh dear, I guess you should read Beginner Mistakes and be prepared for probably the most important learning moment
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]