Thread: Return value to Register

  1. #16
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    That's right, I suppose [I]"a = y" will become "y[a] = i" then? I don't see any toher options. So the code
    Code:
    Register[0] = *( ( unsigned char* ) ( IOBASE + 0x10 ) );
    Backwards will be
    Code:
    ( int ( IOBASE + 0x10 ) ) = unsigned char;
    Or not?

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm sorry to have to say this, but I think you need to read chapters 1, 2 and 3 or so of your C programming book - you are currently trying to swim in the deep end, and you can't even swim in the shallow end with floating aids.

    --
    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.

  3. #18
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    Thank you for your compliment, you are right though. This code will be my first code ever written in program languace. Actually yesterday I kept trying to find the right code. I believe this is it
    Code:
     *( (unsigned char*)( IOBASE + 0x10 ) ) = ddr;
    Thank you for being critic on my work. It get's the best out of me

  4. #19
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Now we're going somewhere. Is that working right for you?

    --
    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.

  5. #20
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
     *( (unsigned char*)( IOBASE + 0x10 ) ) = ddr;
    This is not what I would term 'Beginner's material.' Perhaps you might want to start with the fundamentals of pointers and such before you try to tackle something like this. Even to fairly experienced programmers this line of code is quite ugly.

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Bubba View Post
    Code:
     *( (unsigned char*)( IOBASE + 0x10 ) ) = ddr;
    This is not what I would term 'Beginner's material.' Perhaps you might want to start with the fundamentals of pointers and such before you try to tackle something like this. Even to fairly experienced programmers this line of code is quite ugly.
    I agree - this is NOT beginner C, which is why I suggested to the OP to re-read the first few chapters in the C book.

    Yes, if you read back to my original proposal, I was actually intending to hide all those casts inside a macro [at least, that way, the code looks a bit tidier]. For some reason or another the OP decided to not follow that pattern.

    --
    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