Files
CE2801-Workspace/lab8adc/Src/delay.s
Trevor Barnes ecd65b11b4 class done
2019-11-24 23:51:24 -06:00

60 lines
764 B
ArmAsm

# delay.s
# Trevor Barnes
# CE2801-031
# Description: A file for handling delay routines
.syntax unified
.cpu cortex-m4
.thumb
.section .text
.global msDelay
# A subroutine to create a delay of a certain number of milliseconds
# Input:
# r0: Length of delay (ms)
msDelay:
push {r1,r2,r3,lr}
mov r3,r0
ms_delay:
# 250 iterations = 1/16 of a millisecond
mov r2, #0x10
# Loop 16 times
1:
# 250
mov r1, #0xFA
# Loop 250 times
2:
sub r1, #1
cmp r1, #0
bne 2b
sub r2, #1
cmp r2, #0
bne 1b
sub r0, #1
cmp r0, #0
bne ms_delay
mov r0,r3
pop {r1,r2,r3,pc}
.global usDelay
# about r1 mircoseonds
usDelay:
# stack
push {lr}
lsl r1, r1, #3
1:
sub r1, r1, #1
cmp r1, #0
bne 1b
# return
pop {pc}