I'm learning assembly language and trying to do the following, pretty easy task for the Cortex M0 32bit microcontroller:
So far I just wrote the beginning which is:
MOVS R0, #1 ;a = 1 MOVS R1, #2 ;b = 2 MOVS R2, #3 ;c = 3
and here are the if statements:
if a == 1 b = b * 4 + 2
if a <= b c = 12 b = c + 4
return b // need to return to R0
How do I make it work in assembly language? It would be nice to have comments next to the code so I know what it is doing.
Thanks! I came up with a code, I think it'll do the trick.
The Cortex-M0 assembler is more restrictive due to the way the ISA is implemented.
www.microdigitaled.com/.../ARM_ASM_books.htm
I'm going to work on it today. This is the first programming language I'm trying to learn.
Andrew, thank you for the link, this book looks promising!
Get yourself a copy of this book:
store.elsevier.com/product.jsp
Break the problem down into smaller pieces. Solve the math portion of the problem, then add code to do comparisons and branches.
I was going to type out some sample code for you, but then found myself using google to check minor detail. The detail was very easy to find. Why don't you give it a go?
View all questions in Keil forum