3

How can I perform restricted instructions such as IN and OUT from protected mode?

I've found out that It would require privilege level (CPL) high enough to perform the IO instruction. How can I run in kernel mode, have IO permission or anything other that may help me? - I would like to have direct access to hardware, without anything blocking me.

Thanks.

6
  • Assuming you're running under a third-party operating system, you'll need to write a kernel-mode driver. How you do this is highly dependent on exactly what OS you have. Also, it might help to know exactly what you're trying to do with this. Do you want to program some kind of unusual hardware, or do you have another goal in mind? Commented Aug 9, 2010 at 22:58
  • 1
    Actually I am trying to access simple hardware such as the keyboard. You can take a look at this question: stackoverflow.com/questions/219120? that's basically what I'm trying to do - access IO devices using the IN and OUT, just as the first answer on the link given suggests. Commented Aug 9, 2010 at 23:23
  • 3
    I might add that I'm making a 16bit assembly application, which would probably be emulated using DOS-Box Commented Aug 9, 2010 at 23:25
  • Oh, OK. That's a rather different situation. Under DOS, your code runs in real mode, where hardware protection is basically irrelevant. You should be able to executes IN and OUT instructions from here without any trouble. If you do have a problem with code that you know should work, it might be caused by inaccurate emulation on the part of DOSBox. I would think that basic keyboard IO would work, though. Commented Aug 10, 2010 at 2:36
  • someone tried the code using dosemu running on the console and he said that it worked fine. However, when I try my code using DOS-Box, it doesn't work. Do you have any suggestions? Commented Aug 10, 2010 at 12:25

1 Answer 1

1

DOS is not a protected mode OS. In the olden days there were PM frameworks called DOS extenders. They have an API for things like this. Creating your own PM environment consists of much more than just switching the CPU to Protected Mode.

You should also use a debugger program to check what exactly is wrong under DosBox.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.