UNLIMITED

CQ Amateur Radio

microcontrollers in amateur radio

Using C Pointers: Step 2

In Step 1 of this series, we showed how much work the compiler has to do to process simple statements like these:

int x;

int y;

x = 5;

y = x;

After the definition (not declaration) of x and y, verbalizing the last statement, we can say: “Find the lvalue (i.e., memory address) of x’s bucket and grab the rvalue inside that bucket. Now get the lvalue of y’s bucket, and take x’s rvalue (i.e., 5) and dump it into y’s bucket located at its lvalue.” Note: “normal” assignment expressions in C involve taking the rvalue of one variable and making it the rvalue of a different variable. That is, assignment statements are usually rvalue to rvalue.

We can illustrate this with . When we defined , assumed the compiler assigns it memory address 1000. When we defined , the compiler assigned memory address 1002. On the Arduino Uno or Nano, integer values are 16-bit numbers, so 2 bytes of memory are allocated for each variable. On a 32-bit processor, each variable would have been assigned 4 bytes of memory. (The compiler doesn’t shows the location in memory (i.e., the lvalue) of the two variables as well as their values (rvalue). Sticking with our bucket analogy discussed in my previous column, the variables are depicted as buckets residing in memory.

You’re reading a preview, subscribe to read more.

More from CQ Amateur Radio

CQ Amateur Radio1 min read
On the Cover …
Vladimir Kovaceski, Z35M, is ham radio’s “marathon man.” His first CQ article, back in 2005, described his making more than 43,000 contacts the previous year. He’s checked in periodically with us since then, writing about various additional feats and
CQ Amateur Radio3 min read
Antennas
I have been doing a lot of work on direction-finding antennas lately, so it sure seemed like it would be a good topic for this issue. In Photo A, we have the classic ferrite rod antenna used in most AM radios, often called a wave magnet in the early
CQ Amateur Radio3 min read
Table 1. Parts List
All Resistors are 1/4-watt R1, R2, R3, R4, R5: 1K, Digi Key CF14JT1K00CT-ND - Cut Tape(CT) R6, R7, R8, R9, R10: 10K, Digi Key CF14JT10K0CT-ND - Cut Tape(CT) R11: 5K single-turn linear taper potentiometer, Digi Key 987-1311-ND or Amazon ASIN # B0744G6

Related