Microcontroller & Embedded Systems
1. Write ARM assembly language program to display "Hello World"
AREA HelloW, CODE, READONLY
SWI_WriteC EQU &0
SWI_Exit EQU &11
ENTRY
START ADR R1, TEXT
LOOP LDRB R0, [R1], #1
CMP R0, #0
SWINE SWI_WriteC
BNE LOOP
SWI SWI_Exit
TEXT = "HELLO WORLD", &0a, &0d, 0
END
2. Write ARM assembly language program to find the one's complement (inverse) of a number.
AREA Program, CODE, READONLY
ENTRY
Main
LDR R1, Value ; Load the number to be complemented
MVN R1, R1 ; take 1's complement of R1
STR R1, Result ; Store the result
SWI &11
Value DCD &FF ; Value to be complemented
Result DCD &ABCD1234 ; Storage for result
END
3. Write an assembly language program to compute 4x2 +3x... ... if x is stored in r1. Store the result in r0.
AREA equation, CODE, READONLY
ENTRY
start
MUL r0, r1, r1 ; result <-- x * x
LDR r2, =4 ; tmp <-- 4
MUL r0, r2, r0 ; result <-- 4 * x * x
LDR r2, =3 ; tmp <-- 3
MUL r2, r1, r2 ; tmp <-- x * tmp
ADD r0, r0, r2 ; result <-- result + tmp
stop B stop
end
1. Write ARM assembly language program to display "Hello World"
AREA HelloW, CODE, READONLY
SWI_WriteC EQU &0
SWI_Exit EQU &11
ENTRY
START ADR R1, TEXT
LOOP LDRB R0, [R1], #1
CMP R0, #0
SWINE SWI_WriteC
BNE LOOP
SWI SWI_Exit
TEXT = "HELLO WORLD", &0a, &0d, 0
END
2. Write ARM assembly language program to find the one's complement (inverse) of a number.
AREA Program, CODE, READONLY
ENTRY
Main
LDR R1, Value ; Load the number to be complemented
MVN R1, R1 ; take 1's complement of R1
STR R1, Result ; Store the result
SWI &11
Value DCD &FF ; Value to be complemented
Result DCD &ABCD1234 ; Storage for result
END
3. Write an assembly language program to compute 4x2 +3x... ... if x is stored in r1. Store the result in r0.
AREA equation, CODE, READONLY
ENTRY
start
MUL r0, r1, r1 ; result <-- x * x
LDR r2, =4 ; tmp <-- 4
MUL r0, r2, r0 ; result <-- 4 * x * x
LDR r2, =3 ; tmp <-- 3
MUL r2, r1, r2 ; tmp <-- x * tmp
ADD r0, r0, r2 ; result <-- result + tmp
stop B stop
end
No comments:
Post a Comment