Go Down

Topic: Arduino Due blink example in assembly (Read 10999 times) previous topic - next topic

graynomad

Now we see why inline assembly is such a nightmare :)

Although you could wrap those two bits of code in single asm{} blocks to reduce typing a little.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

blackcoursar

Quote

void setup()
{
    asm volatile("mov r0, %[val]"::[val] "r" (&REG_PIOB_OER));
    asm volatile("mov r1, #1, lsl #27");
    asm volatile("str r1, [r0]");
}

void loop()
{
    asm volatile("mov r0, %[val]"::[val] "r" (&REG_PIOB_SODR));
    asm volatile("mov r1, #1, lsl #27");
    asm volatile("str r1, [r0]");
    asm volatile("ldr r0,=1000");
    asm volatile("bl delay");
    asm volatile("mov r0, %[val]"::[val] "r" (&REG_PIOB_CODR));
    asm volatile("mov r1, #1, lsl #27");
    asm volatile("str r1, [r0]");
    asm volatile("ldr r0,=1000");
    asm volatile("bl delay");
}

Posted on: December 02, 2013, 05:18:21 pm
Posted by: blackcoursar

All i can say is that reading through arm assembly and inline assembly is a subject that really needs a lot of time.
Thank you for the help.

graynomad

Quote
a subject that really needs a lot of time.

Yep, you would need a real good reason to do it.

Once upon a time assembly is all we had and you do get to the point where you have so many libraries etc that you can write code pretty fast. These days most of us have got a life and use C (if you can call that getting a life :))

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Gericom


Quote
a subject that really needs a lot of time.

Yep, you would need a real good reason to do it.

Once upon a time assembly is all we had and you do get to the point where you have so many libraries etc that you can write code pretty fast. These days most of us have got a life and use C (if you can call that getting a life :))

_____
Rob

But assembly is sometimes just more efficient. And for exact timing purposes.
Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

graynomad

True, especially for exact timing, like I said "you would need a real good reason to do it."

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up