this Keil uVision program should load a positive whole ASCII number (e.g 1234). The Program should convert it into BCD coded number in Register R1 , and the HEX number in Register 2... can someone explain me what it does below? especially :
MOV R4,#10
and
AND R1,R3,#0xF
MLA R2,R4,R2,R3
??? here is the program:
LDR R0, =Wert ; Pointer laden
LDR R1,[R0]
BL KONVERT ; Unterprogramm KONVERT aufrufen
endlos B endlos
KONVERT
LDRB R3,[R0],#1 ; Byte laden
AND R1,R3,#0xF ; ASCII-HEX-Wandlung
MOV R2,R1 ; HEX-Zahl
MOV R4,#10
LDRB R3,[R0],#1 ; nächstes laden
AND R3,R3,#0xF ; ASCII-Hex-Wandlung
ORR R1,R3,R1,LSL #4 ; BCD-Wert bilden
MLA R2,R4,R2,R3 ; HEX-Zahl
LDRB R3,[R0],#1 ; nächstes laden
AND R3,R3,#0xF ; ASCII-Hex-Wandlung
ORR R1,R3,R1,LSL #4 ; BCD-Wert bilden
MLA R2,R4,R2,R3 ; HEX-Zahl
LDRB R3,[R0],#1 ; nächstes laden
AND R3,R3,#0xF ; ASCII-Hex-Wandlung
ORR R1,R3,R1,LSL #4 ; BCD-Wert bilden
MLA R2,R4,R2,R3 ; HEX-Zahl
BX LR ; Rücksprung
MOV R4,#10
; loads constant 10 decimal into R4
AND R1,R3,#0xF
; 0x0F & R3 are stored in R1 (AND operation). This is used to remove the 0x30 offset of the numbers 0-9 in ASCII
MLA R2,R4,R2,R3
; (R2 * R4) + R3 are stored in R2 (Multiply-Accumulate operation)
The ARM Infocenter is a good starting point for such questions.