For me, indirection is the holy grail of programming. Indirection allows me to make my code more generalized in such a way to make the changes (that always become necessary) to the program without having to go through and edit parts of the program line-by-line.Indirection
From Wikipedia, the free encyclopedia
In computer programming, indirection (also called "dereferencing") is the ability to reference something using a name, reference, or container instead of the value itself. The most common form of indirection is the act of manipulating a value through its memory address. For example, accessing a variable through the use of a pointer.
Here are a few ways that I provide indirection in my programming. Changes are made in one place. These references in my code never change.
ADDRESSES: Address references can change for all sorts of reasons. One obvious reason is that you might have to change processors. However, if in your definitions of constants, you had referenced all of your addresses by indirection, you would have saved so much work.
symbol LED_1 = 0x01 + 0xC0 symbol LED_2 = 0x03 + 0xC0 symbol LED_3 = 0x05 + 0xC0 symbol LED_4 = 0x07 + 0xC0 symbol LED_5 = 0x09 + 0xC0 symbol LED_6 = 0x0B + 0xC0 symbol LED_7 = 0x0D + 0xC0 symbol LED_8 = 0x0F + 0xC0
symbol PACKETRAM_BEG = 56 ; packet symbol PACKETRAM_END = PACKETRAM_BEG + 7 ; 8 bytes inclusive symbol SANDBOX_BEG = PACKETRAM_END + 1 ; 10 bytes for temporary storage symbol SANDBOX_END = SANDBOX_BEG + 9 ; 10 bytes for temporary storage
symbol d_strobe = B.2 ; strobe symbol d_clk = B.3 ; clock (output pin) symbol d_data = B.4 ; data (output pin for shiftout)