This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Delay Subroutine LPC2148 Assembly

Hi Experts,

I have just started with ARM assembly, I have written a program in assembly for toggling GPIO. The issue that I am facing is that the code works when I use several "nop" in place of "bl delay". The code goes below:

.equ IODIR0, 0xE0028008
.equ IOCLR0, 0xE002800C
.equ IOSET0, 0xE0028004

delay:
   mov r0, #10 
dowaitloop:
   subs r0,#1
   bne dowaitloop
   bx lr  

MOV r3, #0xFFFFFFFF
LDR r4, =IODIR0
LDR r1, =IOCLR0
LDR r2, =IOSET0

str r3, [r4]

loop:
    str r3, [r1]
    bl delay
    str r3, [r2]
    bl delay
b loop

 

 

Commands that I execute to compile:
arm-none-eabi-as -gcoff -o blinky.o blinky.s
arm-none-eabi-ld -e0x00000000 -Ttext=0x00000000 -o blinky.elf blinky.o

arm-none-eabi-objcopy -Oihex blinky.elf blinky.hex

Parents
  • Hi,
    could I ask the start point of your program?
    If it was 'delay:', the program would not work correctly because the branch target of 'bx lr' would be unknown.
    How about putting the delay function below the 'b loop'?
    Best regards,
    Yasuhiko Koumoto.

Reply
  • Hi,
    could I ask the start point of your program?
    If it was 'delay:', the program would not work correctly because the branch target of 'bx lr' would be unknown.
    How about putting the delay function below the 'b loop'?
    Best regards,
    Yasuhiko Koumoto.

Children