473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How does this vector table initialization code works?

The code snippet below is initializing a vector interrupt table a location 0x00000000, and I quite don't understand the syntax. I understand that g_pfnVectors is an array of constant pointers to void. I don't understand the (void) just before the equal sign? The other statement that I don't understand it the casting of __STACK_TOP. It looks like it's casting it to an unsigned long void pointer to void, but what I don't get is the '&' in front of __STACK_TOP?

#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((unsigned long)&__STACK_TOP),

ResetISR,
NmiSR,
FaultISR,
IntDefaultHandler,
IntDefaultHandler,
IntDefaultHandler,
0,
0,
0,
0,
IntDefaultHandler,
IntDefaultHandler,
0,

};
Jan 21 '11 #1
2 7234
Banfa
9,065 Expert Mod 8TB
I understand that g_pfnVectors is an array of constant pointers to void
In that case what you understand is wrong.

It is an array of pointers to functions that take no parameters and return nothing, i.e. the prototype is void fn(void);. That is why there are brackets round the g_pfnVectors bit of the declaration and the void in brackets afterwards is declaring the parameter list.

It is not unknown for the first entry in the interrupt table of a microprocessor to point to the program, so in this case I guess that __STACK_TOP equates to the start of the program. This sort of variable is often highly platform dependent, the & gets the address of __STACK_TOP which is presumably the start of the program.

What platform does this run on?
Jan 21 '11 #2
Banfa, Thank-you for your reply. Your explanation clear it up perfectly. The code snippet is from Stellaris ARM Cortex-M3 LM3S811 processor startup code. The memory model layout has the stack location at address zero followed by exception function handlers.
Jan 21 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: ding feng | last post by:
I am a beginner. So this question could be very stupid. Would anyone help me to solve this problem? A formatted txt file is read. Then i need to look into a vector who is a member of a class to...
1
by: Razarr69 | last post by:
I have a ASP application that I am using for my company and it is currently running on a Windows 2000 server box with IIS 5. The code works perfectly there (except for handling large files - due...
7
by: kittykat | last post by:
Hey everyone, I know this is a stupid question, BUT, i have read both the c++ books i have at home, and have searched through several websites...but i still can't find the answer. The question is,...
1
by: Avi | last post by:
Hi All. This code works very fine in Firefox but not in I.E. Can anybody help me out? it gives ... "Unknown Runtime Error" in I.E. This code ... Stores N*2 Matrix at Client Side & provide the...
6
by: Crash | last post by:
C# VS 2003 ..Net Framework V1.1 SP1 SQL Server 2000 SP3 Enterprise Library June 2005 I'm working with some code {not of my creation} that performs the following sequence of actions: - Open...
7
by: gyan | last post by:
follwing code gives error: 1 #include<iostream.h> 2 int main() 3 { 4 int a=5,b; 5 switch(a){ 6 case 1: 7 {b=5; 8 break; 9 }
1
by: raylegendkiller | last post by:
NEED TO MAKE A PROGRAM which computes the current value of the vectors {x} based on the following forward iterations: this >>> {x}(n+1) = {x}(n), n = 0,1,2, ... ,8,9. In other...
2
by: SM | last post by:
Hello, How hard could it be to create the embeded youtube object in JavaScript DOM ? .... I've create the code and it works ok in Firefox but in IE7 i get an invalid argument error. Can...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
The function that I'm trying to call through DLLImport has a parameter that has a C code's vector's Itrator to a structure. I Have marshalled the structure in C# but how do I do the C type...
1
by: reemamg | last post by:
I've two frames in a page. On the left Frame i've buttons , if we click on button the particular pages will be loaded in the middle Frame. This code works perfectly in Firefox but not in IE ... ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.