How do you disassemble an Arduino program written in C that includes OUTPUT, etc

I’m attempting to disassemble the code below, but keep getting errors that OUTPUT, HIGH, and LOW are undefined. I’m using avr-gcc. I’d like to see the .s file for it, tha assembly language.

/*

  • Show messages on an 8x8 led matrix,
  • scrolling from right to left.
  • Uses FrequencyTimer2 library to
  • constantly run an interrupt routine
  • at a specified frequency. This
  • refreshes the display without the
  • main loop having to do anything.

*/

#include <FrequencyTimer2.h>

#define SPACE {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}

#define H {
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0}
}

#define E {
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0}
}

#define L {
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0}
}

#define O {
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}
}

byte analogPin = 5;
byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
// sets the pins as output
for (int i = 1; i <= 16; i++) {
pinMode(pins*, OUTPUT);*

  • }*
  • // set up cols and rows*
  • for (int i = 1; i <= 8; i++) {*
  • digitalWrite(cols[i - 1], LOW);*
  • }*
  • for (int i = 1; i <= 8; i++) {*
  • digitalWrite(rows[i - 1], LOW);*
  • }*
  • clearLeds();*
  • // Turn off toggling of pin 11*
  • FrequencyTimer2::disable();*
  • // Set refresh rate (interrupt timeout period)*
  • FrequencyTimer2::setPeriod(2000);*
  • // Set interrupt routine to be called*
  • FrequencyTimer2::setOnOverflow(display);*
  • setPattern(pattern);*
    }
    void loop() {
  • pattern = ++pattern % numPatterns;*
  • slidePattern(pattern, 60);*
    }
    void clearLeds() {
  • // Clear display array*
  • for (int i = 0; i < 8; i++) {*
  • for (int j = 0; j < 8; j++) {*
    _ leds*[j] = 0;_
    _
    }_
    _
    }_
    _
    }_
    void setPattern(int pattern) {
    _
    for (int i = 0; i < 8; i++) {_
    _
    for (int j = 0; j < 8; j++) {_
    leds_[j] = patterns[pattern][j];
    }
    }
    }
    void slidePattern(int pattern, int del) {
    for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 8; j++) {
    leds[j] = leds[j][i+1];
    }
    }
    for (int j = 0; j < 8; j++) {
    leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del);
    }
    }
    // Interrupt routine*

    void display() {
    * digitalWrite(cols[col], LOW); // Turn whole previous column off*
    * col++;
    if (col == 8) {
    col = 0;
    }
    for (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
    digitalWrite(rows[row], LOW); // Turn on this led*

    * }
    else {
    digitalWrite(rows[row], HIGH); // Turn off this led*

    * }
    }
    digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
    delayMicroseconds(900); // Delay so that on times are longer than off time = brighter leds*

    }
    ERRORS:
    scroll.c: In function ‘setup’:
    scroll.c:11:25: error: ‘OUTPUT’ undeclared (first use in this function)
    pinMode(rowPins*, OUTPUT);
    ^
    scroll.c:11:25: note: each undeclared identifier is reported only once for each function it appears in
    scroll.c:12:30: error: ‘HIGH’ undeclared (first use in this function)
    digitalWrite(rowPins, HIGH);
    ^
    scroll.c:14:33: error: ‘LOW’ undeclared (first use in this function)
    digitalWrite(columnPins, LOW);
    ^
    scroll.c: In function ‘loop’:
    scroll.c:20:30: error: ‘LOW’ undeclared (first use in this function)
    digitalWrite(rowPins[y], LOW);
    ^
    scroll.c:22:36: error: ‘HIGH’ undeclared (first use in this function)
    digitalWrite (columnPins, HIGH);
    ^*_

Disassemble is not the correct word.

That is what you do (or try to do) when you have the code in Hex numbers and you want to try to figure out the program.

As you seem to have some error messages maybe you meant to say “debug”

If you post your code properly so that it does not have italics or smileys I could copy it to my text editpr to study it. Use the code button </> so your code looks like this.

What version of the Arduino IDE are you using ?

Is this code you wrote yourself?
Sometimes when you copy code from a webpage it can contain strange characters that the Arduino IDE does not recognize.

…R

What on earth are you doing?

You say disassemble (which means taking a compiled program and trying to get back to code), but you're posting errors that appear to be produced while compiling (ie, doing the exact opposite of disassembling).

If you compile with the IDE, things like HIGH, LOW, etc are defined. If it's not, there's something wrong with the IDE. So you're not building with the IDE... but somehow it's not choking on digitalRead() etc (which are in files included by arduino.h - specifically wiring_digital I think) - maybe it would once the arguments were defined.

Those constants are #defines (not variables) here: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h

So yeah, I'm really confused as to wtf you're trying to do...