Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ------------------------------------------------------------------
- ; -- _____ ______ _____ -
- ; -- |_ _| | ____|/ ____| -
- ; -- | | _ __ | |__ | (___ 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_15_8;
- LDRB R1,[R0]
- LSLS R1, R1, #24
- ; Operand A is in R1
- LDR R0,=ADDR_DIP_SWITCH_7_0;
- LDRB R2,[R0]
- LSLS R2, R2, #24
- ; Operand B is in R2
- ADDS R3,R1,R2
- ; R3 is addition result
- MRS R4,APSR
- LSRS R4,R4,#24
- ; R4 is addition flag
- SUBS R5,R1,R2
- ; R5 is subtraction result
- MRS R6,APSR
- LSRS R6,R6,#24
- ; R4 is subtraction flag
- ; Addition display
- LDR R0,=ADDR_LED_7_0
- LSRS R3,R3,#24
- STRB R3,[R0]
- ; Addition flag disply
- LDR R0,=ADDR_LED_15_8
- STRB R4,[R0]
- ; Subtraction display
- LDR R0,=ADDR_LED_23_16
- LSRS R5,R5,#24
- STRB R5,[R0]
- ; Subtraction flag disply
- LDR R0,=ADDR_LED_31_24
- STRB R6,[R0]
- ; END: To be programmed
- B user_prog
- ALIGN
- ; ------------------------------------------------------------------
- ; End of code
- ; ------------------------------------------------------------------
- ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement