Thread: Return value to Register

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No keywords[1] involved here, but perhaps you want to think about how you would do the exact opposite of what your leesRegister does.

    [1] keywords in C are the words defined by the compiler, such as "if", "while", etc.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #2
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    How does a code, that does the exact opposite, look like?
    Code:
    #define IOBASE 0x4000
    
    void schrijfRegister( unsigned char* ddr ) 
    {
      ddr[0] = *( ( unsigned char* ) ( IOBASE + 0x10 ) );
      ddr[2] = *( ( unsigned char* ) ( IOBASE + 0x12 ) );  
      ddr[4] = *( ( unsigned char* ) ( IOBASE + 0x14 ) );
    }
    is this correct?
    Last edited by Lettin03; 11-26-2007 at 06:24 AM.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Lettin03 View Post
    How does a code, that does the exact opposite, look like?
    Code:
    #define IOBASE 0x4000
    
    void schrijfRegister( unsigned char* ddr ) 
    {
      ddr[0] = *( ( unsigned char* ) ( IOBASE + 0x10 ) );
      ddr[2] = *( ( unsigned char* ) ( IOBASE + 0x12 ) );  
      ddr[4] = *( ( unsigned char* ) ( IOBASE + 0x14 ) );
    }
    is this correct?
    No, that's EXACTLY THE SAME, not the OPPOSITE.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    Could you show how the opposite looks like then? I cant figure it out and it's driving me crazy

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Lettin03 View Post
    Could you show how the opposite looks like then? I cant figure it out and it's driving me crazy
    Give it a try - think about what you want to do. Your first function reads FROM a register, the new function should do what?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    Uhm I'm thinking about the same code, but = means the variable becomes. Should I use ==?

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Lettin03 View Post
    Uhm I'm thinking about the same code, but = means the variable becomes. Should I use ==?
    So what do you actually say that this function should do: describe what it does in words, and I think it will be clear to you what you need to do and how to write the code!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 05:03 AM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM