2022-10-14 07:53:24 +02:00
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; -- _____ ______ _____ -
|
|
|
|
|
; -- |_ _| | ____|/ ____| -
|
|
|
|
|
; -- | | _ __ | |__ | (___ Institute of Embedded Systems -
|
|
|
|
|
; -- | | | '_ \| __| \___ \ Zurich University of -
|
|
|
|
|
; -- _| |_| | | | |____ ____) | Applied Sciences -
|
|
|
|
|
; -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; --
|
|
|
|
|
; -- table.s
|
|
|
|
|
; --
|
|
|
|
|
; -- CT1 P04 Ein- und Ausgabe von Tabellenwerten
|
|
|
|
|
; --
|
|
|
|
|
; -- $Id: table.s 800 2014-10-06 13:19:25Z ruan $
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
;Directives
|
|
|
|
|
PRESERVE8
|
|
|
|
|
THUMB
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; -- Symbolic Literals
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
ADDR_DIP_SWITCH_7_0 EQU 0x60000200
|
|
|
|
|
ADDR_DIP_SWITCH_15_8 EQU 0x60000201
|
|
|
|
|
ADDR_DIP_SWITCH_31_24 EQU 0x60000203
|
|
|
|
|
ADDR_LED_7_0 EQU 0x60000100
|
|
|
|
|
ADDR_LED_15_8 EQU 0x60000101
|
|
|
|
|
ADDR_LED_23_16 EQU 0x60000102
|
|
|
|
|
ADDR_LED_31_24 EQU 0x60000103
|
|
|
|
|
ADDR_BUTTONS EQU 0x60000210
|
2022-10-14 11:32:53 +02:00
|
|
|
|
ADDR_7_SEGMENT EQU 0x60000114
|
2022-10-14 07:53:24 +02:00
|
|
|
|
|
|
|
|
|
BITMASK_KEY_T0 EQU 0x01
|
|
|
|
|
BITMASK_LOWER_NIBBLE EQU 0x0F
|
2022-10-14 11:32:53 +02:00
|
|
|
|
SHIFT_BITS_MSB EQU 0x08
|
2022-10-14 07:53:24 +02:00
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; -- Variables
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
AREA MyAsmVar, DATA, READWRITE
|
|
|
|
|
; STUDENTS: To be programmed
|
|
|
|
|
|
2022-10-14 11:32:53 +02:00
|
|
|
|
store_table SPACE 32 ; reserve 16 byte (4 words)
|
2022-10-14 09:51:31 +02:00
|
|
|
|
|
2022-10-14 07:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; END: To be programmed
|
|
|
|
|
ALIGN
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; -- myCode
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
AREA myCode, CODE, READONLY
|
|
|
|
|
|
|
|
|
|
main PROC
|
|
|
|
|
EXPORT main
|
|
|
|
|
|
|
|
|
|
readInput
|
|
|
|
|
BL waitForKey ; wait for key to be pressed and released
|
|
|
|
|
; STUDENTS: To be programmed
|
2022-10-14 09:51:31 +02:00
|
|
|
|
; Read Valules from Dip Switches 7-0 to R0
|
|
|
|
|
LDR R0, =ADDR_DIP_SWITCH_7_0
|
|
|
|
|
LDRB R0, [R0]
|
|
|
|
|
|
|
|
|
|
; Write Values to LED 7-0 from R0
|
|
|
|
|
LDR R1, =ADDR_LED_7_0
|
|
|
|
|
STRB R0, [R1]
|
|
|
|
|
|
|
|
|
|
; Read Index from Dip Switches 15-8 to R1
|
|
|
|
|
LDR R1, =ADDR_DIP_SWITCH_15_8
|
|
|
|
|
LDRB R1, [R1]
|
|
|
|
|
LDR R2, =BITMASK_LOWER_NIBBLE
|
|
|
|
|
ANDS R1, R1, R2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Write Index to LED 15-8 from R1
|
|
|
|
|
LDR R2, =ADDR_LED_15_8
|
|
|
|
|
STRB R1, [R2]
|
|
|
|
|
|
|
|
|
|
; Write Values to Store Table
|
2022-10-14 11:32:53 +02:00
|
|
|
|
MOVS R3, R1
|
|
|
|
|
LDR R2, =SHIFT_BITS_MSB
|
|
|
|
|
LSLS R3, R3, R2
|
|
|
|
|
ADDS R0, R0, R3 ; or w<>re besser
|
2022-10-14 09:51:31 +02:00
|
|
|
|
LDR R2, =store_table
|
2022-10-14 11:32:53 +02:00
|
|
|
|
ADDS R1, R1, R1
|
|
|
|
|
STRH R0, [R2, R1]
|
|
|
|
|
|
|
|
|
|
|
2022-10-14 09:51:31 +02:00
|
|
|
|
|
2022-10-14 07:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
2022-10-14 09:51:31 +02:00
|
|
|
|
; Read Index from Dip Switches 15-8 to R1
|
|
|
|
|
; Todo: Maskierung
|
|
|
|
|
LDR R0, =ADDR_DIP_SWITCH_31_24
|
|
|
|
|
LDRB R0, [R0]
|
|
|
|
|
LDR R1, =BITMASK_LOWER_NIBBLE
|
|
|
|
|
ANDS R0, R0, R1
|
|
|
|
|
|
|
|
|
|
; Write Index to LED 15-8 from R1
|
|
|
|
|
LDR R1, =ADDR_LED_31_24
|
|
|
|
|
STRB R0, [R1]
|
|
|
|
|
|
|
|
|
|
; Read Values from Store Table
|
|
|
|
|
LDR R1, =store_table
|
2022-10-14 11:32:53 +02:00
|
|
|
|
ADDS R0, R0, R0
|
|
|
|
|
LDRH R0, [R1, R0]
|
2022-10-14 09:51:31 +02:00
|
|
|
|
|
|
|
|
|
; Write Values to LED 7-0 from R0
|
|
|
|
|
LDR R1, =ADDR_LED_23_16
|
|
|
|
|
STRB R0, [R1]
|
2022-10-14 11:32:53 +02:00
|
|
|
|
|
|
|
|
|
;Write Values to 7-Segment Display
|
|
|
|
|
LDR R1, =ADDR_7_SEGMENT
|
|
|
|
|
STRH R0, [R1]
|
2022-10-14 07:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; END: To be programmed
|
|
|
|
|
B readInput
|
|
|
|
|
ALIGN
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; Subroutines
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
; wait for key to be pressed and released
|
|
|
|
|
waitForKey
|
|
|
|
|
PUSH {R0, R1, R2}
|
|
|
|
|
LDR R1, =ADDR_BUTTONS ; laod base address of keys
|
|
|
|
|
LDR R2, =BITMASK_KEY_T0 ; load key mask T0
|
|
|
|
|
|
|
|
|
|
waitForPress
|
|
|
|
|
LDRB R0, [R1] ; load key values
|
|
|
|
|
TST R0, R2 ; check, if key T0 is pressed
|
|
|
|
|
BEQ waitForPress
|
|
|
|
|
|
|
|
|
|
waitForRelease
|
|
|
|
|
LDRB R0, [R1] ; load key values
|
|
|
|
|
TST R0, R2 ; check, if key T0 is released
|
|
|
|
|
BNE waitForRelease
|
|
|
|
|
|
|
|
|
|
POP {R0, R1, R2}
|
|
|
|
|
BX LR
|
|
|
|
|
ALIGN
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
; End of code
|
|
|
|
|
; ------------------------------------------------------------------
|
|
|
|
|
ENDP
|
|
|
|
|
END
|