您的位置:首页 > 编程语言 > C语言/C++

Jump Tables via Function Pointer Arrays in C/C++

2012-09-16 09:16 330 查看
by Nigel
Jones


=================================================================================================================

Jump tables, also called branch tables, are an efficient means of handling similar events in software. Here's a look at the use of arrays of function pointers in C/C++ as
jump tables.


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Examination of assembly language code that has been crafted by an expert will usually reveal extensive use of function "branch tables." Branch tables (a.k.a.,
jump tables) are used because they offer a unique blend of compactness and execution speed, particularly on microprocessors that support indexed addressing. When one examines typical C/C++ code, however, the branch table (i.e., an array of funtion pointers)
is a much rarer beast. The purpose of this article is to examine why branch tables are not used by C/C++ programmers and to make the case for their extensive use. Real world examples of their use are included.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

更多请参考阅读: http://www.barrgroup.com/Embedded-Systems/How-To/C-Function-Pointers



..............................................................................................................................................................................................................................................................
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: