Thread: what does this line do?

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    52

    what does this line do?

    Hi everyone,

    I am not sure what this line is doing...


    #define VECTOR_BASE 0xBFC0
    #define SWIV (*(volatile int *)(VECTOR_BASE + 0x36)) /* SWI */

    This is what I'm guessing it does. It takes the address VECTOR_BASE then adds 0x36 to that address and arrives at another adress which is then defined as SWIV. I don't understand why all that casting is necessary?

    Would this also accomplish the same?

    #define SWIV (*(unsigned char *)(VECTOR_BASE + 0x36)) /* SWI */

    Any help appreciated,
    Ted.

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    Would this also accomplish the same?
    no. one is volatile int * and the other is unsigned char *.
    i do not see why vector base was declared twice.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    SWIV is a function pointer. VECTOR_BASE is not an address, it's just an integer value.

    Quote Originally Posted by kryptkat View Post
    i do not see why vector base was declared twice.
    It wasn't.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    52
    Quote Originally Posted by MK27 View Post
    SWIV is a function pointer. VECTOR_BASE is not an address, it's just an integer value.



    It wasn't.
    Thank you so much, that shed some light into the problem.. so if that's a function pointer.. then that is the interrupt handler hmmmmm.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I believe you want an int for an interrupt.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do encryption in C
    By sankarv in forum C Programming
    Replies: 33
    Last Post: 12-28-2010, 11:01 AM
  2. Reading a file line by line
    By Raskalnikov in forum C Programming
    Replies: 8
    Last Post: 03-18-2009, 11:44 PM
  3. Pointer and Polymorphism help.
    By Skyy in forum C++ Programming
    Replies: 29
    Last Post: 12-18-2008, 09:17 PM
  4. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  5. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM