I am attempting to write assembly code for my EK-TM4C129EXL that will turn on LED’s 3 and 4 when user switch one is pressed, wait a few seconds and then turn off the LED’s. Then if the other user switch is pressed, turn on the other LED’s. I have the C code written and it works. I turned it into assembly and I keep getting the following C file and line pop up:
It is always the same highlighted line (133) and my code does not work. I am not sure why this is happening. I do not see anything wrong with my code. The only thing missing from my code is the timer which I will add later. Here though is my assembly code:
.thumb
.text
.align 4
GPIO_PORTN .word 0x40064000
GPIO_PORTJ .word 0x40060000
GPIO_PORTF .word 0x4005D000
SYSCTL .word 0x400fe000
.align 4
GPIO_PIN_0 .equ (1>>0)
GPIO_PIN_1 .equ (1<<1)
GPIO_PIN_4 .equ (1<<4)
.align 4
LED1_PN1 .equ GPIO_PIN_1
LED2_PN0 .equ GPIO_PIN_0
LED3_PF4 .equ GPIO_PIN_4
LED4_PF0 .equ GPIO_PIN_0
.align 4
SYSCTL_RCGCGPIO_PORTF .equ (1<<5)
SYSCTL_RCGCGPIO_PORTJ .equ (1<<8)
SYSCTL_RCGCGPIO_PORTN .equ (1<<12)
.align 4
PUSH1_PJ0 .equ GPIO_PIN_0
PUSH2_PJ1 .equ GPIO_PIN_1
.align 4
SYSCTL_RCGCGPIO .equ 0x608
GPIO_DIR .equ 0x400
GPIO_PUR .equ 0x510
GPIO_DEN .equ 0x51c
.global main
main:
.align 4
push {R0-R5,LR}
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTN
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTN
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTF
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTF
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTJ
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTJ
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DIR]
orr R0, #LED1_PN1
str R0, [R1, #GPIO_DIR]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DIR]
orr R0, #LED2_PN0
str R0, [R1, #GPIO_DIR]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DIR]
orr R2, #LED3_PF4
str R2, [R3, #GPIO_DIR]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DIR]
orr R2, #LED4_PF0
str R2, [R3, #GPIO_DIR]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DEN]
orr R0, #LED1_PN1
str R0, [R1, #GPIO_DEN]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DEN]
orr R0, #LED2_PN0
str R0, [R1, #GPIO_DEN]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DEN]
orr R2, #LED3_PF4
str R2, [R3, #GPIO_DEN]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DEN]
orr R2, #LED4_PF0
str R2, [R3, #GPIO_DEN]
ldr R5, GPIO_PORTJ
ldr R4, [R5, #GPIO_PUR]
orr R4, #PUSH1_PJ0
orr R4, #PUSH2_PJ1
str R4, [R5, #GPIO_PUR]
ldr R5, GPIO_PORTJ
ldr R4, [R5, #GPIO_DEN]
orr R4, #PUSH1_PJ0
orr R4, #PUSH2_PJ1
str R4, [R5, #GPIO_DEN]
b loop
pop {R0-R5,PC}
loop:
ldr R5, GPIO_PORTJ
ldr R4, [R5, #PUSH2_PJ1]
cmp R4, #0
bne left
ldr R4, [R5, #PUSH1_PJ0]
cmp R0, #0
bne right
b loop
left:
ldr R1, GPIO_PORTN
ldr R0, [R1, #LED1_PN1]
eor R0, #LED1_PN1
str R0, [R1, #LED1_PN1]
ldr R1, GPIO_PORTN
ldr R0, [R1, #LED2_PN0]
eor R0, #LED2_PN0
str R0, [R1, #LED2_PN0]
b loop
right:
ldr R3, GPIO_PORTF
ldr R2, [R3, #LED3_PF4]
eor R2, #LED3_PF4
str R2, [R3, #LED3_PF4]
ldr R3, GPIO_PORTF
ldr R2, [R3, #LED4_PF0]
eor R2, #LED4_PF0
str R2, [R3, #LED4_PF0]
b loop
.end
Any guidance would be appreciated. Thank you.
I am attempting to write assembly code for my EK-TM4C129EXL that will turn on LED’s 3 and 4 when user switch one is pressed, wait a few seconds and then turn off the LED’s. Then if the other user switch is pressed, turn on the other LED’s. I have the C code written and it works. I turned it into assembly and I keep getting the following C file and line pop up:
It is always the same highlighted line (133) and my code does not work. I am not sure why this is happening. I do not see anything wrong with my code. The only thing missing from my code is the timer which I will add later. Here though is my assembly code:
.thumb
.text
.align 4
GPIO_PORTN .word 0x40064000
GPIO_PORTJ .word 0x40060000
GPIO_PORTF .word 0x4005D000
SYSCTL .word 0x400fe000
.align 4
GPIO_PIN_0 .equ (1>>0)
GPIO_PIN_1 .equ (1<<1)
GPIO_PIN_4 .equ (1<<4)
.align 4
LED1_PN1 .equ GPIO_PIN_1
LED2_PN0 .equ GPIO_PIN_0
LED3_PF4 .equ GPIO_PIN_4
LED4_PF0 .equ GPIO_PIN_0
.align 4
SYSCTL_RCGCGPIO_PORTF .equ (1<<5)
SYSCTL_RCGCGPIO_PORTJ .equ (1<<8)
SYSCTL_RCGCGPIO_PORTN .equ (1<<12)
.align 4
PUSH1_PJ0 .equ GPIO_PIN_0
PUSH2_PJ1 .equ GPIO_PIN_1
.align 4
SYSCTL_RCGCGPIO .equ 0x608
GPIO_DIR .equ 0x400
GPIO_PUR .equ 0x510
GPIO_DEN .equ 0x51c
.global main
main:
.align 4
push {R0-R5,LR}
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTN
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTN
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTF
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTF
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTJ
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, SYSCTL
ldr R0, [R1, #SYSCTL_RCGCGPIO]
orr R0, #SYSCTL_RCGCGPIO_PORTJ
str R0, [R1, #SYSCTL_RCGCGPIO]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DIR]
orr R0, #LED1_PN1
str R0, [R1, #GPIO_DIR]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DIR]
orr R0, #LED2_PN0
str R0, [R1, #GPIO_DIR]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DIR]
orr R2, #LED3_PF4
str R2, [R3, #GPIO_DIR]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DIR]
orr R2, #LED4_PF0
str R2, [R3, #GPIO_DIR]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DEN]
orr R0, #LED1_PN1
str R0, [R1, #GPIO_DEN]
ldr R1, GPIO_PORTN
ldr R0, [R1, #GPIO_DEN]
orr R0, #LED2_PN0
str R0, [R1, #GPIO_DEN]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DEN]
orr R2, #LED3_PF4
str R2, [R3, #GPIO_DEN]
ldr R3, GPIO_PORTF
ldr R2, [R3, #GPIO_DEN]
orr R2, #LED4_PF0
str R2, [R3, #GPIO_DEN]
ldr R5, GPIO_PORTJ
ldr R4, [R5, #GPIO_PUR]
orr R4, #PUSH1_PJ0
orr R4, #PUSH2_PJ1
str R4, [R5, #GPIO_PUR]
ldr R5, GPIO_PORTJ
ldr R4, [R5, #GPIO_DEN]
orr R4, #PUSH1_PJ0
orr R4, #PUSH2_PJ1
str R4, [R5, #GPIO_DEN]
b loop
pop {R0-R5,PC}
loop:
ldr R5, GPIO_PORTJ
ldr R4, [R5, #PUSH2_PJ1]
cmp R4, #0
bne left
ldr R4, [R5, #PUSH1_PJ0]
cmp R0, #0
bne right
b loop
left:
ldr R1, GPIO_PORTN
ldr R0, [R1, #LED1_PN1]
eor R0, #LED1_PN1
str R0, [R1, #LED1_PN1]
ldr R1, GPIO_PORTN
ldr R0, [R1, #LED2_PN0]
eor R0, #LED2_PN0
str R0, [R1, #LED2_PN0]
b loop
right:
ldr R3, GPIO_PORTF
ldr R2, [R3, #LED3_PF4]
eor R2, #LED3_PF4
str R2, [R3, #LED3_PF4]
ldr R3, GPIO_PORTF
ldr R2, [R3, #LED4_PF0]
eor R2, #LED4_PF0
str R2, [R3, #LED4_PF0]
b loop
.end
Any guidance would be appreciated. Thank you.