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,

    the _start symbol would be useless because there is no means to initiate from the _start.

    If you use assembler, you had better put the vector table from the address 0x0.

    The program will begin with the address 0x0.

    For exsample:

    .global _start
    
    .equ IODIR0, 0xE0028008
    .equ IOCLR0, 0xE002800C
    .equ IOSET0, 0xE0028004
    
    .text
       b _start
       b undef_handler
       b SVC_handler
       b PAbt_handelr
       b DAbt_handler
       b RFU_handler
       b IRQ_handler
       b FIQ_handler
    undef_handler:
    SVC_handler:
    PAbt_handelr:
    DAbt_handler:
    RFU_handler:
    IRQ_handler:
    FIQ_handler:
       b undef_handler /* do nothing */
    
    delay:
       mov r0, #10 
    dowaitloop:
       subs r0,#1
       bne dowaitloop
       bx lr 
    
    _start:
    MOV r3, #0xFFFFFFFF
    LDR r4, =IODIR0
    LDR r1, =IOCLR0
    LDR r2, =IOSET0
    str r3, [r4]
    loop:
    
    str r3, [r2]
    
    bl delay
    
    str r3, [r1]
    bl delay
    b loop
    

    Best regards,

    Yasuhiko Koumoto.

Reply
  • Hi,

    the _start symbol would be useless because there is no means to initiate from the _start.

    If you use assembler, you had better put the vector table from the address 0x0.

    The program will begin with the address 0x0.

    For exsample:

    .global _start
    
    .equ IODIR0, 0xE0028008
    .equ IOCLR0, 0xE002800C
    .equ IOSET0, 0xE0028004
    
    .text
       b _start
       b undef_handler
       b SVC_handler
       b PAbt_handelr
       b DAbt_handler
       b RFU_handler
       b IRQ_handler
       b FIQ_handler
    undef_handler:
    SVC_handler:
    PAbt_handelr:
    DAbt_handler:
    RFU_handler:
    IRQ_handler:
    FIQ_handler:
       b undef_handler /* do nothing */
    
    delay:
       mov r0, #10 
    dowaitloop:
       subs r0,#1
       bne dowaitloop
       bx lr 
    
    _start:
    MOV r3, #0xFFFFFFFF
    LDR r4, =IODIR0
    LDR r1, =IOCLR0
    LDR r2, =IOSET0
    str r3, [r4]
    loop:
    
    str r3, [r2]
    
    bl delay
    
    str r3, [r1]
    bl delay
    b loop
    

    Best regards,

    Yasuhiko Koumoto.

Children
No data