I have tried that and it gave me 100's of lines of code which didnt seem correct and when i tried to run it, it had a bunch of errors. Unless i did it completely wrong do you know?
I only, ever, tried it once, back in about 1988. I was going to write data communication software for PCs using 80386 and 80486. I had to use assembly for speed, I thought. When I began in C and printed the assembly output to use as a base for the program, I immediately changed my mind. I ended up writing the whole program in C and never had a problem with speed!
So, I never went beyond that one time.
Perhaps you have a different reason?
I'd leave the original C++ lines in, and comment them as you add your asm volatile lines.
As is, it is unclear how you expect the these to match behavior:
int red =10;
int yellow =9;
int green =8;
void setup() {
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}
void loop() {
changeLights();
delay(1000);
}
void changeLights(){
//green off, yellow on for 3 seconds
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(3000);
//turm off yellow, then turn red on for 5 seconds
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(5000);
//red and yellow on for 2 seconds (red is still on from previous code)
digitalWrite(yellow, HIGH);
delay(2000);
//turn off red and yellow, then turn on green
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(3000);
}
ive just never used assembly code so when i run the assembly code the LED's do work i just want the amber light to stay on with the green light like the original code and im not sure how to do that
Yeah haha this is a task on an assignment of mine, I know how to do C perfectly but we have never done assembly and i dont really know why we have to do it haha but oh well. Im sure i can figure this out anyhow!
I'm not an assembly type person but I've read in this forum messages from assembly programmers looking at the output of the C compiler for hints on how to improve their code. However often the man made code was better but the compiler is very good and can provide useful hints on how to do certain coding functions.
My take away was the comparison between a programmer and the compiler is similar to a comparison between a programmer and another programmer.
My goal is to literally have the normal C code to work as assembly code aswell, when i have used a compiler it has given me 100's of lines of codes and gave me tons of errors, I may have done this wrong however so you got any way to do this correctly?