You are on page 1of 4

18BMC304J-Laboratory

Date:
Ex. No: 10

ALP TO PERFORM ARITHMETIC OPERATIONS

Aim:

To write an assembly language program to perform arithmetic operations.

Program:
i. ALP to perform Addition
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
main
LDR R1, =0x00001133
LDR R2, =0x00001111
ADD R3, R1,R2
;MOV R1, #0x33 ;R1 = 33
;MOV R2, #0x11 ;R2 = 11
;ADD R3, R1, R2 ;/* R3 = R1 + R2 */
HERE
B HERE ;/* End loop */
END ;/* End of file */
ii. ALP to perform Subtraction
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
main
;/* Write your assembly language code starting after this line. */
MOV R1, #0x44
MOV R2, #0x11
SUB R3, R1, R2 ;/* R2 = R1 - R2 */
;/* Finish your assembly language code before this line. */
HERE
B HERE ;/* End loop */

Register No:________________________
18BMC304J-Laboratory

END ;/* End of file */


iii. ALP to perform Multiplication
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
main
;/* Write your assembly language code starting after this line. */
MOV R1, #0x5
MOV R2, #0x2
MUL R3, R1, R2 ;/* R2 = R1 x R2 */
;/* Finish your assembly language code before this line. */
HERE
B HERE ;/* End loop */
END ;/* End of file */
iv. ALP to perform Division
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
main
;/* Write your assembly language code starting after this line. */
MOV R0, #100 ;/* Dividend */
MOV R1, #10 ;/* Divider */

MOV R3, #0 ;/* Quotient in R3 */


LOOP
CMP R0, R1
BLT DONE
ADD R3, R3, #1 ;/* R3 = R3 + 1 */
SUB R0, R0, R1 ;/* R0 = R0 - R1 */
B LOOP ;/* Jump to LOOP */
;/* Quotient in R3 & Reminder in R0 */
DONE
;/* Finish your assembly language code before this line. */
HERE

Register No:________________________
18BMC304J-Laboratory

B HERE ;/* End loop */


END ;/* End of file */
Output:

Register No:________________________
18BMC304J-Laboratory

Result:

Thus, the assembly language program to generate sawtooth waveform using the 8051
microcontroller was written and executed successfully.

Register No:________________________

You might also like