Building register array (C) -


for embedded application in c, want array of registers can accessed host system. each register has following field:

address (32 bits), value (32 bits), callback (32 bits)

now, suppose have hundreds of these registers. efficient way point right register when host wants access 1 particular register base on address? note address values not continued.

doing if/else or switch/case structure out of question , parsing register register not efficient.

the best way have found define each register this:

regstruct * registername = ( (regstruct*) address_of_register);

but way, implies address_of_register must valid address in memory map , not portable between platform.

what want let linker place register in memory , access address gave. there way it?


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -