Assembly Programs
Assembly Programs
Write an ALP to i) Multiply two 16-bit binary numbers. ii) Add two 64-bit numbers
ENTRY
LBL
END
OUTPUT: R2=0004
ENTRY
NOP
NOP
END
ENTRY
BNE LOOP
STR R3,[R5]
NOP
NOP
END
MOV R1, R0
BLE STOP
BEQ STOP
MOV R0, R2
B LOOP
STOP NOP
END
4 Write an ALP to add an array of 16-bit numbers and store the 32-bit result
in internal RAM.
AREA ADDITION,CODE,READONLY
ENTRY
MOV R5,#6
MOV R0,#0
LDR R1,=VALUE
ADD R0,R0,R3
SUBS R5,R5,#1
CMP R5,#0
BNE LOOP
LDR R4,=RESULT
STR R0,[R4]
STOP B STOP
AREA INFO,DATA,READWRITE
END
5.Write an ALP to find the square of a number (1 to 10) using look-up table.
ENTRY
LDR R0, =TABLE ;Load the starting address of the Lookup Table
MOV R1, R1, LSL#0X2 ;Generate address corresponding to the square of the
given no
NOP
NOP
NOP
END
ENTRY
CMP R1, R2
BHI SKIP
MOV R1, R2
BHI LOOP
STR R1,[R0]
END
ENTRY
CMP R1, R2
BLE SKIP
MOV R1, R2
BNE LOOP
STR R1,[R0]
END
7. Write an ALP to arrange a series of 32-bit numbers in
ascending/descending order.
i. AREA ASCENDING,CODE,READONLY
ENTRY
MOV R0,#05
MOV R2,#0x40000000
ADD R2,R2,#04
LDR R4,[R2]
CMP R3,R4
BGT SKIP
STR R3,[R2]
SUB R2,R2,#04
STR R4,[R2]
ADD R2,R2,#04
CMP R1,#00
BNE LOOP
SUB R0,R0,#01
CMP R0,#00
BNE AGAIN
NOP
NOP
END
ENTRY
MOV R0,#05
MOV R2,#0x40000000
ADD R2,R2,#04
LDR R4,[R2]
CMP R3,R4
BLT SKIP
STR R3,[R2]
SUB R2,R2,#04
STR R4,[R2]
ADD R2,R2,#04
CMP R1,#00
BNE LOOP
SUB R0,R0,#01
CMP R0,#00
BNE AGAIN
NOP
NOP
END
Expt.8.
i) Write an ALP to count the number of ones and zeros in two consecutive
memory locations.
ENTRY
BHI ONE
B SKIP
BNE HERE
BNE LOOP
NOP
NOP
END
ii. Write an ALP to Scan a series of 32-bit numbers to find how many are
negative.
ENTRY
BLS SKIP
BNE LOOP
NOP
NOP
END