Reading a byte from inp() and DEBUG
Results 1 to 4 of 4

Thread: Reading a byte from inp() and DEBUG

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    8

    Reading a byte from inp() and DEBUG

    Does anybody know why reading a byte from debug (using "i") through DOS produces a different value than reading a byte by using _inp() from <conio.h> from MS VC++? In both cases, you have to specify a hex. address. I am assuming by specifying the same hex address, I should have received the same memory content. But In my case, I am getting two different values. Why is that? Am I comparing apples to oranges in terms of memory location?

  2. #2
    Junior Member
    Join Date
    Jul 2002
    Posts
    11
    What's your C++ code?

    You might put a byte into a 16 or 32 bit word, and print the entire word. But
    hard to tell without your code.

  3. #3
    Junior Member
    Join Date
    Jul 2002
    Posts
    8
    Let's say the code is something simple:
    ------------------------------------------------------------------

    #include <stdio.h>
    #include <conio.h>
    int main(void)
    {
    printf(" [%2x] ",_inp(0x378));
    return 0;
    }

    ------------------------------------------------------------------

    If you try to run this under MS VC++, which is what I'm using, you're going to get "The exception Priviledge instruction. (0xc0000096) occured in the application at location 0x004010f7." So anyway, you can use a program from this link to help you get around that problem: http://www.beyondlogic.org/porttalk/porttalk.htm. Once you have gotten around that problem, you should be able to print out the memory content in 0x378. (after your program is compiled, run the .exe file) Now compare that to the memory content in 0x378 by means of using the debug program in DOS. (use "i" then the port address). You should see the discrepancy. My guess is, somehow MS VC++ is working with offsets. But that is just a guess.

  4. #4
    Senior Member
    Join Date
    Aug 2001
    Posts
    356
    i dont really know, but perhaps _inp() is reading 32 bites, as windows is a 32 bit system, but debug is reading only 16 cause dos only a 16bit system?
    -8-

    There are 10 types of people in this world: those who understand binary, and those who dont.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •