.thumb .syntax unified .include "gpio_constants.s" // Register-adresser og konstanter for GPIO .text .global Start LED_PORT_BASE = GPIO_BASE + (LED_PORT * PORT_SIZE) LED_SET_ADDR = LED_PORT_BASE + GPIO_PORT_DOUTSET LED_CLEAR_ADDR = LED_PORT_BASE + GPIO_PORT_DOUTCLR BUTTON_READ_ADDR = GPIO_BASE + (BUTTON_PORT * PORT_SIZE) + GPIO_PORT_DIN Start: LDR R0, =LED_SET_ADDR LDR R1, =LED_CLEAR_ADDR LDR R2, =BUTTON_READ_ADDR Loop: LDR R3, [R2] // Read value of BUTTON_READ_ADDR AND R3, R3, 1 << BUTTON_PIN // Mask out the bit of interest LSR R3, BUTTON_PIN - LED_PIN // Shift the bit to the LED_PIN position STR R3, [R1] // Store the value into LED_SET_ADDR EOR R3, R3, 1 << LED_PIN // Flip the bit STR R3, [R0] // Store the opposite bit into LED_CLEAR_ADDR B Loop // Repeat NOP