Monthly Archives: March 2016

Arduino Inline Assembly Tutorial (Tables)

Often, the fastest way to compute something on an arduino is to not compute it all. Huh? For example, trigonometric functions are costly operations and can abruptly slow your application to the pace of a crawl. And many times, the … Continue reading

Posted in Uncategorized | Tagged , , , , , | 6 Comments

Arduino Inline Assembly Tutorial (Strings)

Addressing Modes When loading and storing data, there are several addressing methods available for use. The arduino’s AVR microcontroller supports 13 address modes for accessing the Program memory (Flash) and Data memory (SRAM, Register file, I/O Memory, and Extended I/O … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Arduino Inline Assembly Tutorial (Branching)

Loop and Branch Branching is a fundamental feature of computers. For example, branching allows a computer to repeat instruction sequences. One of the most  basic forms of repetition is a “loop”, and the loop is probably the most widely used … Continue reading

Posted in Uncategorized | Tagged , , , , , | 2 Comments

Towards a More General digitalRead

The arduino digitalRead function is a nice bit of code. However, it takes more than a cursory glance to determine exactly how it performs (see Yak Shaving). It also compiles into approximately 222 bytes of code, and its slow in … Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Arduino Inline Assembly Tutorial (Math)

Increment, Decrement, Add and Subtract INC is a mnemonic for INCrement. INC adds one to the contents of the register placing the result back into the register. The C flag in the Status Register (SREG) is not affected by the … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Arduino Inline Assembly Tutorial (Bit Shifts)

Introduction In this tutorial we continue our examination of bit operations. Specifically we discuss left and right shifts. We’ll end this tutorial with an assortment of short C language MACRO code segments that demonstrate checking bits. Shift to Multiply The … Continue reading

Posted in Uncategorized | Tagged , , , , , | 1 Comment

Arduino Inline Assembly Tutorial (Bit Ops)

Introduction Bit operations are the foundation upon which all microcontroller programming builds. A good understanding of bit functions is essential for efficient arduino programming in general, and specifically for inline assembly programming. Its that simple. It really is simple too. … Continue reading

Posted in Uncategorized | Tagged , , , , , | 3 Comments

Arduino µC Status Register (SREG)

Like all microcontrollers the arduino’s AVR µC has a flag register to indicate various conditions. The Status Register is referred to in short as the “SREG”, and can be directly referenced inline using __SREG__. It is an 8-bit wide register, … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Arduino Inline Assembly Tutorial (Ports & Pins)

Mapping Memory The 3 basic types of memory in the arduino were discussed in tutorial #1. Again, here we are interested in SRAM data memory, which the arduino uses as memory-mapped IO. MMIO means that a part of the SRAM … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Arduino Inline Assembly Tutorial #4 (Constraints)

Introduction I have a confession to make. My previous examples were not very efficient assembly code. That might seem like an odd comment, especially since my typical example used just 2-4 lines of code. But, these examples were coded as … Continue reading

Posted in Uncategorized | Tagged , , , , , | 12 Comments