AREA myCODE, CODE, READONLY ; Start of the code section EXPORT Start ; Export the Start function EXTERN setPortF ; External function to initialize Port F EXTERN setPortFInterrupts ; External function to configure Port F interrupts EXPORT GPIOPortF_Handler ; Export the interrupt handler EXTERN delay ; External delay function GPIO_PORTF_DATA_R EQU 0x400253FC ; Address of GPIO Port F data register GPIOF_ICR EQU 0x4002541C ; GPIO Port F Interrupt Clear register GPIOF_MIS EQU 0x40025418 ; GPIO Port F Masked Interrupt Status register SW1 EQU 0x10 ; PF4 (Switch 1) bit mask SW2 EQU 0x01 ; PF0 (Switch 2) bit mask Start PROC BL setPortF ; Initialize Port F BL setPortFInterrupts ; Configure Port F interrupts BX LR ; Exit the Start function ENDP GPIOPortF_Handler PROC LDR R0, =GPIOF_MIS ; Load the address of the Masked Interrupt Status register LDR R1, [R0] ; Read the value from the GPIO Port F Interrupt Masked Status register ; Check if the interrupt is triggered by SW1 (PF4) TST R1, #SW1 ; Perform bitwise AND to check if SW1 was pressed (bit 4 is set) BEQ Check_SW2 ; If no interrupt from SW1, check SW2 LDR R0, =GPIO_PORTF_DATA_R ; Load the address of the GPIO Port F data register MOV R4, #0x02 ; Set the value to 0x02 (turn on red LED) ADD R5, R5, R4 ; Add to R5 (increment logic) STR R5, [R0] ; Write the value to the GPIO Port F data register CMP R5, #0x0A ; Compare R5 with 0x0A BEQ reverse ; Jump to reverse if equal ; Clear the interrupt flag for SW1 LDR R0, =GPIOF_ICR ; Load the address of the Interrupt Clear register MOV R2, #SW1 ; Set the value for PF4 (SW1) to clear the interrupt STR R2, [R0] ; Write to GPIOF_ICR to clear the interrupt flag BX LR ; Exit the interrupt handler Check_SW2 ; Check if the interrupt is triggered by SW2 (PF0) TST R1, #SW2 ; Perform bitwise AND to check if SW2 was pressed (bit 0 is set) BEQ Done_Handler ; If no interrupt from SW2, exit the handler LDR R0, =GPIO_PORTF_DATA_R ; Load the address of the GPIO Port F data register MOV R7, #0x02 ; Set the value to 0x02 (turn off or change LED) SUB R5, R5, R7 ; Subtract from R5 (decrement logic) STR R5, [R0] ; Write the value to the GPIO Port F data register CMP R5, #0x00 ; Compare R5 with 0x00 BEQ reverse2 ; Jump to reverse2 if equal ; Clear the interrupt flag for SW2 LDR R0, =GPIOF_ICR ; Load the address of the Interrupt Clear register MOV R2, #SW2 ; Set the value for PF0 (SW2) to clear the interrupt STR R2, [R0] ; Write to GPIOF_ICR to clear the interrupt flag Done_Handler BX LR ; Exit the interrupt handler ENDP reverse MOV R5, #0x00 ; Reset R5 BX LR ; Exit the handler reverse2 MOV R5, #0x08 ; Set R5 to specific value BX LR ; Exit the handler ALIGN END