C++ Basics Technical Reference

Here is some simple programming syntax to get you started. I might add more here when I get some time. This is very useful if you are just starting out and need to reference some simple information. Amazingly, you take all of this simple stuff, put it together, and make the more complicated stuff...

Integer Data Types

  1: typedef  signed char                      int8_t;
  2: typedef  unsigned char                   uint8_t;
  3: typedef  short                           int16_t;
  4: typedef  unsigned short                 uint16_t;
  5: typedef  long                            int32_t;
  6: typedef  unsigned long                  uint32_t;
  7: typedef  long long                       int64_t;
  8: typedef  unsigned long long             uint64_t;

Logical Bit Operations

  1: X |= (1 << Bitnumber);
  2: // Set the bit as 1.
  3: 
  4: X &= ~(1 << Bitnumber);
  5: // Set the bit as 0.
  6: 
  7: DDRA &= ~(1 << thebit);
  8: // Set the bit to 0 in the DDRA register.
  9: 
 10: DDRA |= (1 << thebit);
 11: // Set the bit to 1 in the DDRA register.

Setting Multiple Bits Simultaneously

  1: DDRA &= ~( (1<<PA0) | (1<<PA3) );
  2: // PA0 and PA3 as inputs in the DDRA register.
  3: 
  4: PORTA |= (1<<PA0) | (1<<PA3);
  5: // Set PA0 and PA3 as 1 in the PortA register.

This Article Continues...

C to ASM Parameter Passing Registers