diff --git a/table_asm/app/table.s b/table_asm/app/table.s index 26e2420..d525a51 100644 --- a/table_asm/app/table.s +++ b/table_asm/app/table.s @@ -27,9 +27,11 @@ ADDR_LED_15_8 EQU 0x60000101 ADDR_LED_23_16 EQU 0x60000102 ADDR_LED_31_24 EQU 0x60000103 ADDR_BUTTONS EQU 0x60000210 +ADDR_7_SEGMENT EQU 0x60000114 BITMASK_KEY_T0 EQU 0x01 BITMASK_LOWER_NIBBLE EQU 0x0F +SHIFT_BITS_MSB EQU 0x08 ; ------------------------------------------------------------------ ; -- Variables @@ -37,7 +39,7 @@ BITMASK_LOWER_NIBBLE EQU 0x0F AREA MyAsmVar, DATA, READWRITE ; STUDENTS: To be programmed -store_table SPACE 16 ; reserve 16 byte (4 words) +store_table SPACE 32 ; reserve 16 byte (4 words) @@ -76,8 +78,15 @@ readInput STRB R1, [R2] ; Write Values to Store Table + MOVS R3, R1 + LDR R2, =SHIFT_BITS_MSB + LSLS R3, R3, R2 + ADDS R0, R0, R3 ; or wäre besser LDR R2, =store_table - STRB R0, [R2, R1] + ADDS R1, R1, R1 + STRH R0, [R2, R1] + + @@ -94,11 +103,16 @@ readInput ; Read Values from Store Table LDR R1, =store_table - LDRB R0, [R1, R0] + ADDS R0, R0, R0 + LDRH R0, [R1, R0] ; Write Values to LED 7-0 from R0 LDR R1, =ADDR_LED_23_16 STRB R0, [R1] + + ;Write Values to 7-Segment Display + LDR R1, =ADDR_7_SEGMENT + STRH R0, [R1] ; END: To be programmed diff --git a/table_asm/app/tableTask1.s b/table_asm/app/tableTask1.s new file mode 100644 index 0000000..26e2420 --- /dev/null +++ b/table_asm/app/tableTask1.s @@ -0,0 +1,136 @@ +; ------------------------------------------------------------------ +; -- _____ ______ _____ - +; -- |_ _| | ____|/ ____| - +; -- | | _ __ | |__ | (___ 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 + +BITMASK_KEY_T0 EQU 0x01 +BITMASK_LOWER_NIBBLE EQU 0x0F + +; ------------------------------------------------------------------ +; -- Variables +; ------------------------------------------------------------------ + AREA MyAsmVar, DATA, READWRITE +; STUDENTS: To be programmed + +store_table SPACE 16 ; reserve 16 byte (4 words) + + + + +; 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 + ; 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 + LDR R2, =store_table + STRB R0, [R2, R1] + + + + ; 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 + LDRB R0, [R1, R0] + + ; Write Values to LED 7-0 from R0 + LDR R1, =ADDR_LED_23_16 + STRB R0, [R1] + + +; 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 diff --git a/table_asm/build/table.axf b/table_asm/build/table.axf index afad2d3..7ba9824 100644 Binary files a/table_asm/build/table.axf and b/table_asm/build/table.axf differ diff --git a/table_asm/build/table.build_log.htm b/table_asm/build/table.build_log.htm index edbb0b3..d39d6f9 100644 --- a/table_asm/build/table.build_log.htm +++ b/table_asm/build/table.build_log.htm @@ -31,12 +31,12 @@ assembling table.s... assembling datainit_ctboard.s... assembling startup_ctboard.s... compiling system_ctboard.c... -compiling hal_pwr.c... compiling hal_fmc.c... -compiling hal_gpio.c... +compiling hal_pwr.c... compiling hal_rcc.c... +compiling hal_gpio.c... linking... -Program Size: Code=3520 RO-data=428 RW-data=16 ZI-data=8192 +Program Size: Code=3544 RO-data=428 RW-data=32 ZI-data=8192 ".\build\table.axf" - 0 Error(s), 0 Warning(s).

Software Packages used:

diff --git a/table_asm/build/table.htm b/table_asm/build/table.htm index 1de362d..9d3c570 100644 --- a/table_asm/build/table.htm +++ b/table_asm/build/table.htm @@ -3,7 +3,7 @@ Static Call Graph - [.\build\table.axf]

Static Call Graph for image .\build\table.axf


-

#<CALLGRAPH># ARM Linker, 6180002: Last Updated: Fri Oct 14 09:50:22 2022 +

#<CALLGRAPH># ARM Linker, 6180002: Last Updated: Fri Oct 14 11:29:33 2022

Maximum Stack Usage = 112 bytes + Unknown(Cycles, Untraceable Function Pointers)

Call chain for Maximum Stack Depth:

@@ -597,7 +597,7 @@ Global Symbols
[Called By] -

main (Thumb, 76 bytes, Stack size 0 bytes, table.o(myCode)) +

main (Thumb, 92 bytes, Stack size 0 bytes, table.o(myCode))

[Calls]


[Called By]