int86 implementation

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.
Post Reply
jasonc122
Member
Member
Posts: 27
Joined: Fri Jan 01, 2010 7:51 am

int86 implementation

Post by jasonc122 »

hi,

I'm unsure of how to go about implementing an int86-like function as found in dos.h. I need to execute video interrupt in real mode and would like guidance on how to implement such a function (code would be nice :shock: )

Thanks
H Technology Solutions - Business Operating System Specialists
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: int86 implementation

Post by Love4Boobies »

Code would be nice but you can't have any because you won't learn anything. That function just loads a bunch of registers from parameters and executes an INT. It's basica assembly. If you can't code it yourself you should probably learn a bit more before taking on OSDev'ing.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
jasonc122
Member
Member
Posts: 27
Joined: Fri Jan 01, 2010 7:51 am

Re: int86 implementation

Post by jasonc122 »

=D> Very helpful

Instead of making me reinvent the wheel please just post the code.
Last edited by jasonc122 on Wed Mar 03, 2010 6:31 pm, edited 1 time in total.
H Technology Solutions - Business Operating System Specialists
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: int86 implementation

Post by pcmattman »

An int86 function changes in complexity depending on if you run in protected mode or not. From your post it sounds like real mode, which means the int86 function is quite elementary to write (as Love4Boobies has already stated).
jasonc122
Member
Member
Posts: 27
Joined: Fri Jan 01, 2010 7:51 am

Re: int86 implementation

Post by jasonc122 »

I'm running in protected mode and need to run an INT in real mode. What's the easiest way to add a 16 bit code thunk (which will include the 16 bit INT instruction) to 32 bit elf? Failing that just please post the code - I'll learn much faster from that
H Technology Solutions - Business Operating System Specialists
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: int86 implementation

Post by pcmattman »

You probably need to actually drop back to real mode and then run the interrupt, and return to protected mode when done.

The alternative is to write a virtual 8086 mode monitor.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: int86 implementation

Post by thepowersgang »

Please stop asking us to post the code, trust me, just blindly copy-and-pasting code will cause no end to hell for you down the line, and you generally don't learn from it.

As pcmattman said, in protected mode you cannot just directly call a BIOS interrupt, instead you either need to drop back to real mode (normally not a good idea) or implement VM8086.

Just out of curiosity, why do you need to call a BIOS int, because unless it's for setting the video mode, it's usually easier to write your own driver for the device, and use that. Calling the BIOS from PMode is ... difficult.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: int86 implementation

Post by ~ »

jasonc122 wrote:I'm running in protected mode and need to run an INT in real mode. What's the easiest way to add a 16 bit code thunk (which will include the 16 bit INT instruction) to 32 bit elf? Failing that just please post the code - I'll learn much faster from that
You could use x86emu (cached here).

Also, you can easily run INT services if you are in real mode, even from the DOS command line, you can see a sample here, just look for the "CPU/opcodes" and "CPU/regs" folders.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: int86 implementation

Post by Creature »

Because of the way you keep asking for code, I doubt a lot of people will give you it.

Anyway, what you're looking for is inside the Intel docs (drop PMode -> RMode, the opposite and the stages in between (16-bit PMode?)). As already was said, the alternative is to implement VM8086. The only thing that might be of help when doing the first is that an easy way to execute 16-bit code is (assuming your OS is running in 32-bit protected mode) to write a flat binary program that you can jump to or call that goes back and forth.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: int86 implementation

Post by Love4Boobies »

It sounds to me like he's in real mode (dos.h).
thepowersgang wrote:Just out of curiosity, why do you need to call a BIOS int, because unless it's for setting the video mode, it's usually easier to write your own driver for the device, and use that. Calling the BIOS from PMode is ... difficult.
It's not difficult, it's just slow, non-re-entrant (which in the end adds to the slowness) and it doesn't provide as many features as a device driver.

I also think the OP has stopped reading the thread.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply