using machine language on the arduino

Vista haters please stand up ! please stand up ! [smiley=tongue.gif]

(Do you have room for people of the tired-of-mac-os-x group ? :D)

I’ve got OSX 10.3.9 on my laptop. I guess I’m tired of it in the sense that now, 4 years later, I really don’t see any real reason to upgrade. There’s really nothing new. I kind of what to take advantage of their free iTouch deal.

ok, about your strange-seeming problem : I’ve had some trouble with DreamWeaver (bwaaaaah) which from time to time added characters into PHP which looked like spaces or tabs, but weren’t, and led the interpreter to return meaningless (at first sight) errors. Have you tried taking an existing and working source code, then remove a curly brace and just retype it ?

Is that a windows problem or DreamWeaver? It sounds really nasty, but I’ve never had it come up. I do most of my coding on winXP (though a little on the laptop).

ok, about your strange-seeming problem : I’ve had some trouble with DreamWeaver (bwaaaaah) which from time to time added characters into PHP which looked like spaces or tabs, but weren’t, and led the interpreter to return meaningless (at first sight) errors. Have you tried taking an existing and working source code, then remove a curly brace and just retype it ?

Is that a windows problem or DreamWeaver? It sounds really nasty, but I’ve never had it come up. I do most of my coding on winXP (though a little on the laptop).

I use Mac OS X as well… I haven’t had similar problems with any other editor I used (jEdit, Eclipse, vi), so I suspect it’s a DreamWeaver problem. But except if his code is itself buggy, which I assume is not the case, I suspect a similar problem.

Vista haters please stand up ! please stand up ! [smiley=tongue.gif]

(Do you have room for people of the tired-of-mac-os-x group ? :D)

ok, about your strange-seeming problem : I’ve had some trouble with DreamWeaver (bwaaaaah) which from time to time added characters into PHP which looked like spaces or tabs, but weren’t, and led the interpreter to return meaningless (at first sight) errors. Have you tried taking an existing and working source code, then remove a curly brace and just retype it ?

Have you tried taking an existing and working source code, then remove a curly brace and just retype it ? YES, and it worked!!
I;m getting tired of blinky patterns.

I have to remark that this is the most mature and technically savy group i have ever come across, I am honored to be a member,

At least you’ll soon be sure you’re not epileptic… If you can post the source code which didn’t compile, it will be easier to help then…

(I just re-read the thread and found out that you said you’ve almost never used C… I’m sorry my previous messages won’t be of any help, I thought you knew C and had some kind of uncommon problem while compiling.)

here’s the code…

here’s the code

//blinking led

int ledPin = 13;

void setup()

{
(pinMode(ledPin, OUTPUT);
}

void loop()

{

digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

here’s the compile error…

In function ‘void setup():
error: expected ‘)’ before’;’ token

As the message says, you have an unclosed parenthesis in setup(); which can also be understood as “too many opening parentheses”

Replace :

(pinMode(ledPin, OUTPUT);

with :

pinMode(ledPin, OUTPUT);

A good way to sort out this kind of problem is to count parentheses, adding 1 for each opening and removing 1 for each closing. If at the end of the line you’re not at 0, then there’s a problem ^^

To help you better understand the compiler’s message, note that the following statement :

(pinMode(ledPin, OUTPUT)); // Adding, as requested by the compiler, a parenthesis before the ;

is also valid, even if the enclosing () are useless.

crud! :’(
I was afraid it would be something simple like that. I can’t blame it on epilepsy either since that was the first thing I put in.
Sorry, I should have caught that myself.

The Arduino environment helps you keep track of curlies and parentheses - if the cursor is just beyond one, the mate will have a box displayed around it. I’ve gotten in the habit of checking my new functions with this handy feature before compiling.

The easiest way to experiment with machine (assembly) language within the arduino environment is to use “inline assembler” within your sketch (which is a C program, after all.) For example, here is the loop() function from the led blink example modified to use assembler to turn the LED pin on and off. There is probably an include file you can add that will get you the expected assembly language “symols” instead of looking up constants.

void loop()                     // run over and over again
{
// digitalWrite(ledPin, HIGH);   // sets the LED on
// Asm experiment.  Note that pin13 is actually b5 of portb,
//  and "portb" is at io register address 5.
  asm("sbi 5,5");
  delay(1000);                  // waits for a second
  asm("cbi 5,5");
//  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

Note that the syntax used by the gnu assembler inline assembly language might not exactly match the syntax published by Atmel in their references. :frowning: This is a general problem with using inline assembler withing a C program.

A good way to LOOK at the assembly language of a sketch is to connect to the applet subdirectory of the sketch (after it has been “verified” (compiled)) and use the avr-objdump to look at it:

/Applications/arduino-0010/hardware/tools/avr/bin/avr-objdump -S led_blink.elf
    :
void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
 136:   61 e0           ldi     r22, 0x01       ; 1
 138:   80 91 00 01     lds     r24, 0x0100
 13c:   0e 94 9f 01     call    0x33e <pinMode>
 140:   08 95           ret
    :

Wow, thankyou. that looks great. I’m going to play with that method tonight.
This is a GREAT little board, the more I read about it and play with it the more I like it.

I really appreciate all you folks taking time to walk me thru my first time usage of this great machine.
Thanks too to all the help with assembly programming!

It would be great to have a little sample of pure asm (maybe something funnier than a blinking led), if you wanna take the time to add a few comments to one of your testing program to make it understandable by people of the procedural-and-object-coding-are-the-only-things-which-exists generation ^^

It would be great to have a little sample of pure asm (maybe something funnier than a blinking led), if you wanna take the time to add a few comments to one of your testing program to make it understandable by people of the procedural-and-object-coding-are-the-only-things-which-exists generation ^^

You can view the asm of any sketch following the procedure westfw posted earlier. Go to your sketch applet directory and run avr-objdump with the –S parameter.

For example, if your arduino directory is on the root and your in a sketch directory called led-blink, after compiling your sketch run the command:

/arduino-0010/hardware/tools/avr/bin/avr-objdump -S led_blink.elf

You will see the assembler code mixed with the c source code. It may help to redirect the output to a text file. There was a batch file posted in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207951658