I just started learning ARM Assembly for the Cortex M4 architecture. I have the basic concepts understood, such as loops, memory access, and proper use of instructions. I've come across another loop type that I tried implementing, the delay loop. I understand the premise, just a loop with a delay in the execution of the next instruction. So I tried my best using the knowledge I have of NOPs, cycle times, and loops, but haven't gotten anywhere. My goal with the delay loop is to print an integer to the terminal every 2 seconds. My initial approach was to try and set up two nested loops and load the cycle time into the registers, this gave me an infinite loop of just strings. I scrapped that idea and have tried the following, but am encountering errors, but believe I'm on the right track.
PRESERVE8
AREA MyCode, CODE, READONLY
EXPORT start
start
import print ;Custom C function that prints a string to screen
MOV R1, #0 ;Number from which the program will count down
loop1
CMP R1, #10 ;Compares the register with 0
BEQ stop ;If true, will jump to stop
BL print ;Calls the C function print to print the number
BLE loop ;Loop back to loop until complete
loop2
LDR R2, =num
STR R1, [R2]
ADDS R1, R1, #1 ;Increments the count
stop
B stop
ALIGN
AREA MyData, DATA, READWRITE
srcstr DCB "String source", 0
END
I've kind of run out of ideas about what to do or where to go from here. Could someone please show me what I'm looking for?
Cheers