Menu

My outportb not working

2002-11-03
2012-09-26
  • Nobody/Anonymous

    I'm trying to read the CMOS RTC directly. I've written my own outportb() as following:

    char RTCAddr, RTCData;  // global variables

    void outportb(int port, char data)
    {
        RTCAddr = port;
        RTCData = data;
        __asm ("mov _RTCAddr,%dx");
        __asm ("mov _RTCData,%al");
        __asm ("out %al,%dx");
    }

    This code compiles ok, but on executon, my outportb() hangs on the last line (out %al,%dx).
    For example
    outportb(0x70, 0);  // address RTC current second
    hangs. What am I doing wrong?

     
    • Nobody/Anonymous

      Oops, a made a typo.
      The global variable definition should read:

      int RTCAddr, RTCData; // global variables

      Anyway, whats wrong with the code?

       
    • Nobody/Anonymous

      Just a wild guess, but you may need to make the asm section critical - ban interrupts 'till you finish out-ing ( lock the WC door ! ;-) )

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.