| RSGC ACES: Register-Level Coding (December 2025) |
A fundamental understanding of the organization and architecture of computer hardware can enhance its performance. Furthermore, writing code in as close to the native language of the processor as possible can eliminate the inefficiencies that creep in through the multiple components in the toolchain (compilers, libraries, etc.). The exercises below introduce you to lower level instruction techniques designed to increase performance by reducing demand on resources.
Task. Review C's bitwise operators and their precedence before completing the sketch below.
// PROJECT : BitsandBytes
// PURPOSE : Bit-level manipulation
// COURSE : TEJ3M
// AUTHOR : C. D'Arcy
// DATE : 2025 12 08
// MCU : 328p (Nano)
// STATUS : Working
// REFERENCE:https://docs.arduino.cc/language-reference/
uint16_t value = 2048;
void setup() {
Serial.begin(9600);
while (!Serial) {}
Serial.println(value);
// multiply by 4
Serial.println(value);
// divide by 8
Serial.println(value);
Serial.println(value,BIN);
//swap the low and high bytes
Serial.println(value, BIN);
// invert all bits
Serial.println(value, BIN);
// invert them again
Serial.println(value, BIN);
//set bit 10
Serial.println(value, BIN);
//clear bit 2
Serial.println(value, BIN);
// toggle bit 10
Serial.println(value, BIN);
}
void loop() {}
2. Register-Level Manipulation of the ATmega328p's GPIO Ports
In this segment you are asked to employ the techniques in Step 1 to manipulate the ATmega328p's digitlal pins in a more direct (and efficient) manner than employing Arduino C's high-level pinMode(), digitalWrite() and digitalRead() functions.
First, understand the memory areas you are exploiting...
| ATmega328p's 3 Memories | ATmega328p's Registers |
|---|---|
![]() |
![]() |
Next, familiarize yourself with the General Purpose Input/Output (GPIO) registers that you will modify,
In this exercise you are asked to take on the built in shiftOut() function through the use of register-level manipulation of the three control lines (data, clock and latch). Having soldered up your Morland bargraph you can place it into the context shown below.

4. ATtiny85 Register-Level Bicolor Blink
In this exercise you are invited to explore the potential benefits of porting your skills (pardon the pun) to ATMEL's 8-bit ATtiny85 MCU. The beauty of the AVR family of MCUs is that they're designed to be portable due to their common instruction set and register architecture. This allows you to transfer much of what you have learned over the past few classes in order to establish an alternate blinking pattern on the Kingbright rectangular bicolor LED given to you.
Task.
![]() |
|
|---|---|
![]() |
![]() |