solved Task 3.2

This commit is contained in:
Schrom01
2022-10-28 10:46:13 +02:00
parent 6f4740e719
commit 36f6411dd2
10 changed files with 294 additions and 155 deletions
+36 -6
View File
@@ -117,15 +117,45 @@ EndCalcByMult
; Add Bin Value in higher Byte in R0
LSLS R2, R2, #8
ORRS R0, R0, R2
; Show R0 on LEDs
LDR R2, =ADDR_LED_15_0
STRH R0, [R2]
; Show R0 on LEDs 15-0
LDR R3, =ADDR_LED_15_0
STRH R0, [R3]
; Show R0 on 7-Segment
LDR R2, =ADDR_7_SEG_BIN_DS3_0
STRH R0, [R2]
LDR R3, =ADDR_7_SEG_BIN_DS3_0
STRH R0, [R3]
; Count positive Bits in Higher Byte of R2 to R1
LDR R1, =0 ; initialize R1 with 0
LDR R3, =0x1 ; mask to set first bit and to substract counter
LDR R4, =9 ; counter for loop
LSLS R2, R2, #16
CheckBitLoop
SUBS R4, R4, R3
BEQ EndCheckBitLoop ; goto EndCheckBitLoop if R4 (counter) = 0
LSLS R2, R2, #1 ; Shift Bits in R2
BCC CheckBitLoop ; goto CheckBitLoop if carry = 0
ORRS R1, R3 ; Add Carry to R1
LSLS R1, R1, #1 ; Shift Bits in R1
B CheckBitLoop ; goto checkBitLoop
EndCheckBitLoop
LSRS R1, R1, #1 ; Shift Bits in R1
; Rotate LEDs 31-16
LDR R2, =ADDR_LED_31_16
LDR R4, =17 ; Counter for LedRotationLoop
LedRotationLoop
SUBS R4, R4, R3
BEQ EndLedRotationLoop ; goto EndCheckBitLoop if R4 (counter) = 0
BL pause
STRH R1, [R2] ; Show R1 on LEDs 31-16
MOV R5, R1 ; Coppy R1 to R5
LSLS R5, R5, #16 ; Shift Bits in R5
ORRS R1, R1, R5 ; Coppy lower bytes of R1 in upper bytes in R1
RORS R1, R1, R3
B LedRotationLoop
EndLedRotationLoop
; END: To be programmed