0% found this document useful (0 votes)
51 views

Microcontroller and Embedded Systems Laboratory: Subject

This document contains instructions for two programs to run on an ARM7TDMI/LPC2148 microcontroller. Program 1 multiplies two 16-bit numbers by loading them into registers, multiplying the registers, and storing the result. Program 3 calculates the factorial of a number in two different ways: 1) by iteratively multiplying a starting number by descending integers, and 2) recursively calling a multiplication subroutine. Both methods store the final result in memory.

Uploaded by

rakshitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Microcontroller and Embedded Systems Laboratory: Subject

This document contains instructions for two programs to run on an ARM7TDMI/LPC2148 microcontroller. Program 1 multiplies two 16-bit numbers by loading them into registers, multiplying the registers, and storing the result. Program 3 calculates the factorial of a number in two different ways: 1) by iteratively multiplying a starting number by descending integers, and 2) recursively calling a multiplication subroutine. Both methods store the final result in memory.

Uploaded by

rakshitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Subject: MICROCONTROLLER AND

EMBEDDED SYSTEMS LABORATORY

PROGRAM 1
AND
PROGRAM 3
PART A:

Conduct the following experiments by writing


program using ARM7TDMI/LPC2148 using an
evaluation board/simulator and the required
software tool.
Lab Program 1: Write a program to multiply two 16 bit binary numbers.

AREA MULTIPLY, CODE, READONLY


ENTRY

LDRH R1,M ;16-bit half word number


LDRH R2,N
MUL R3,R1,R2

LDR R0,=RESULT
STR R3,[R0]

B1 B B1 ;optional

M DCW 5
N DCW 6
AREA MYDATA, DATA, READWRITE
RESULT DCD 0x0

END
Lab Program 3: Write a program to find factorial of a number
METHOD 1:
AREA FACT, CODE, READONLY
ENTRY
MOV R0, #5 ; STORE FACTORIAL NUMBER IN R0
MOV R5, #5 ; MOVE THE SAME NUMBER IN R1

LOOP SUB R5, R5, #1 ; NEXT NO


MUL R0, R5, R0 ; MULTIPLICATION-can’t write MUL R0,R0,R5 → error
CMP R5, #1 ; STOP IF THE NO BECOMES 1
BNE LOOP

LDR R4, =RESULT


STR R0, [R4]

AREA MYDATA, DATA, READWRITE


RESULT DCD 0x0

END
Lab Program 3: Write a program to find factorial of a number
METHOD 2:
AREA FACT, CODE, READONLY
ENTRY
MOV R0, #5 ; STORE FACTORIAL NUMBER IN R0
MOV R1, R0 ; MOVE THE SAME NUMBER IN R1
MOV R3, #1 ; DEFAULT VALUE OF R3 SET TO 1

FACT1 SUB R1, R1, #1 ; NEXT NO


CMP R1, #1 ; STOP IF THE NO BECOMES 1
BEQ STOP
MUL R3, R0, R1 ; MULTIPLICATION
MOV R0, R3
B FACT1 ; UNCONDITIONAL BRANCHING

STOP LDR R4, =RESULT


STR R3, [R4]

AREA MYDATA, DATA, READWRITE


RESULT DCD 0x0

END

You might also like