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

Mes Lab Programs

The document contains summaries of 8 lab programs that perform various operations: 1. Multiplies two 16-bit binary numbers. 2. Calculates the sum of the first 10 integers. 3. Finds the factorial of a number. 4. Adds an array of 16-bit numbers and stores the 32-bit result. 5. Finds the square of a number using a lookup table. 6. Finds the largest number in an array of integers. 7. Sorts an array of integers in descending order. 8. Counts the number of 1s in the binary representation of a number.

Uploaded by

natty singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Mes Lab Programs

The document contains summaries of 8 lab programs that perform various operations: 1. Multiplies two 16-bit binary numbers. 2. Calculates the sum of the first 10 integers. 3. Finds the factorial of a number. 4. Adds an array of 16-bit numbers and stores the 32-bit result. 5. Finds the square of a number using a lookup table. 6. Finds the largest number in an array of integers. 7. Sorts an array of integers in descending order. 8. Counts the number of 1s in the binary representation of a number.

Uploaded by

natty singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB PROGRAM 1- Multiplication of 2 16 bit binary

numbers
Lp1 AREA MULTIPLY,CODE,READONLY

LDR R0,=X

LDR R1,=Y

LDRH R0,[R0]

LDRH R1,[R1]

MUL R2,R1,R0

LOOP B LOOP

X DCW 0X0012

Y DCW 0X0004

END

LAB PROGRAM 2- Sum of first 10 integers


Lp2 AREA SUM10,CODE,READONLY

MOV R0,#10

MOV R1,R0

AGAIN

SUB R0,#1

ADD R1,R0

CMP R0,#1

BNE AGAIN

LOOP B LOOP

END

LAB PROGRAM 3 - to find the factorial of a


number
Lp3 AREA FACT,CODE,READONLY

MOV R0,#4

MOV R1,R0

AGAIN
SUB R0,#1

MUL R2,R1,R0

MOV R1,R2

CMP R0,#1

BNE AGAIN

LOOP B LOOP

END

LAB PROGRAM 4- to add an array of 16 bit numbers


and store the 32 bit result in internal RAM

AREA ABC, CODE,READONLY

LDR R0,=ARRAY

AGAIN

LDRH R1,[R0],#2

ADD R2,R1

CMP R1,#0

BNE AGAIN

LDR R3,=ANS

STR R2,[R3]

LOOP B LOOP

ARRAY DCW 0X1111,0X2222,0X3333,0X4444,0X3333,0X5555

ARRAYEND DCW 0

ALIGN

AREA DES,DATA,READWRITE

ANS DCD 0

LAB PROGRAM 5 -  to find the square of a


number (1 to 10) using look-up table
AREA SQRT, CODE, READONLY

NUM EQU 6

BASE RN R1

LDR BASE,=SQRS

LDRB R2,[BASE,#NUM]

STOP B STOP

SQRS DCB 0,1,4,9,16,25,36,49,64,81,100

ALIGN

END

LAB PROGRAM 6
AREA LARGEST,CODE,READONLY

ENTRY

START

MOV R5,#6

LDR R1,=ARRAY

LDR R2,[R1],#4

AGAIN

LDR R4,[R1],#4

CMP R2,R4

BLS AGAIN1

MOV R2,R4

AGAIN1

SUBS R5,R5,#1

CMP R5,#0

BNE AGAIN

LOOP B LOOP

ARRAY DCD 0X120,0X520,0X100,0X600,0X900,0X450,0X100


END

LAB PROGRAM 7
AREA Program,CODE,READONLY

MOV R5, #4

OUTER

MOV R6, R5

LDR R0, =0X40000000

INNER

LDR R1, [R0]

LDR R2, [R0, #4]

CMP R1, R2

BLO SKIP

STR R2, [R0]

STR R1, [R0, #4]

SKIP

ADD R0, R0, #4

SUBS R6, #1

BNE INNER

SUBS R5, #1

BNE OUTER

LOOP B LOOP

END

LAB PROGRAM 8
AREA PROGRAM, CODE, READONLY

ENTRY

LDRH R0, VALUE

MOV R1, #0x10


LOOP MOVS R0, R0, RRX

ADDCC R3, R3, #1

ADDCS R2, R2, #1

SUBS R1, R1, #1

BNE LOOP

STOP B STOP

VALUE DCW 0x00000002

END

You might also like