; ------------------------------------------------------------------ ; -- _____ ______ _____ - ; -- |_ _| | ____|/ ____| - ; -- | | _ __ | |__ | (___ Institute of Embedded Systems - ; -- | | | '_ \| __| \___ \ Zurich University of - ; -- _| |_| | | | |____ ____) | Applied Sciences - ; -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland - ; ------------------------------------------------------------------ ; -- ; -- sumdiff.s ; -- ; -- CT1 P05 Summe und Differenz ; -- ; -- $Id: sumdiff.s 705 2014-09-16 11:44:22Z muln $ ; ------------------------------------------------------------------ ;Directives PRESERVE8 THUMB ; ------------------------------------------------------------------ ; -- Symbolic Literals ; ------------------------------------------------------------------ ADDR_DIP_SWITCH_7_0 EQU 0x60000200 ADDR_DIP_SWITCH_15_8 EQU 0x60000201 ADDR_LED_7_0 EQU 0x60000100 ADDR_LED_15_8 EQU 0x60000101 ADDR_LED_23_16 EQU 0x60000102 ADDR_LED_31_24 EQU 0x60000103 ; ------------------------------------------------------------------ ; -- myCode ; ------------------------------------------------------------------ AREA MyCode, CODE, READONLY main PROC EXPORT main user_prog ; STUDENTS: To be programmed LDR R0, =ADDR_DIP_SWITCH_7_0 LDRB R0, [R0] ; Read DIP Switch 7-0 in R0 LSLS R0, R0, #24 ; cast to 32 Bit LDR R1, =ADDR_DIP_SWITCH_15_8 LDRB R1, [R1] ; Read DIP Switch 15-8 in R0 LSLS R1, R1, #24 ; cast to 32 Bit LDR R2, =ADDR_LED_7_0 ADDS R3, R0, R1 ; Add R0 + R1 MRS R5, APSR ; Read Flags to R5 LSRS R3, R3, #24 ; Move MSB to LSB STRB R3, [R2] ; Show LSB in LEDs 7-0 LDR R2, =ADDR_LED_15_8 LSRS R5, R5, #24 ; Move Flags 24 Bit right STRB R5, [R2] ; Show Flags in LED 15-12 LDR R2, =ADDR_LED_23_16 SUBS R3, R0, R1 ; Sub R0 - R1 MRS R5, APSR ; Read Flags to R5 MRS R5, APSR ; Read Flags to R5 LSRS R3, R3, #24 ; Move MSB to LSB STRB R3, [R2] ; Show LSB in LEDs 15-8 LDR R2, =ADDR_LED_31_24 LSRS R5, R5, #24 ; Move Flags 24 Bit right STRB R5, [R2] ; Show Flags in LED 15-12 ; END: To be programmed B user_prog ALIGN ; ------------------------------------------------------------------ ; End of code ; ------------------------------------------------------------------ ENDP END