0% found this document useful (0 votes)
5 views5 pages

Ass 3

The document contains solutions for four assembly language programming (ALP) assignments related to embedded systems. It includes code for checking if a number is prime, counting positive and negative numbers in a list, transferring memory blocks, and exchanging data blocks. Each section provides the corresponding assembly code and outlines the expected memory locations for input and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Ass 3

The document contains solutions for four assembly language programming (ALP) assignments related to embedded systems. It includes code for checking if a number is prime, counting positive and negative numbers in a list, transferring memory blocks, and exchanging data blocks. Each section provides the corresponding assembly code and outlines the expected memory locations for input and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Embedded System

Lab
ASSIGNMENT 3 SOLUTION

Vaibhav Vardhan Tyagi


REG NO :- 20223302
1. Write an ALP to check whether a given number is prime or not.
Assume that the number is stored at location 20H. Store FFH at
location 30H if the number is prime, otherwise store 00H.

MOV R7, 20H


MOV R6, #02H
TOP: MOV B, R6
MOV A, R7
SETB C
SUBB A, B
JC DONE
MOV A, R7
MOV B, R6
DIV AB
MOV R4, B
INC R6
CJNE R4,#00H,TOP
MOV 30H, #00H
SJMP HERE
DONE: MOV 30H, #0FFH
HERE: SJMP HERE

Output:

2. Write an ALP to determine the number of positive and negative


numbers in a list of ten numbers. Assume that the look up table for
the list is stored in ROM location 0250H. Store the counts for
positive and negative numbers at RAM locations 20H and 21H,
respectively.

ORG 0250H
DB 0FFH, 0F1H, 02H, 0E0H, 0AAH, 11H, 21H, 81H, 51H, 0E1H
ORG 0000
MOV DPTR, #0250H
MOV R2, #0AH
MOV R5, #00H
MOV R6, #00H
TOP: CLR A
MOVC A, @A+DPTR
MOV R7, A
RLC A
JNC SKIP
INC R6
SJMP DONE
SKIP: INC R5
DONE: INC DPTR
DJNZ R2, TOP
MOV 20H, R5
MOV 21H, R6
HERE: SJMP HERE

Output:

3. Write a ALP for non-overlapping (10 Bytes from 20H to 40H


onwards) and overlapping (10 Bytes from 20H to 25H onwards)
memory block transfer.
->Non-Overlap
MOV R0, #20H
MOV R1, #40H
MOV R2, #0AH
LOOP1: MOV A, @R0
MOV @R1, A
INC R0
INC R1
DJNZ R2, LOOP1
HERE: SJMP HERE

->Overlap
MOV R0, #29H
MOV R1, #2DH
MOV R2, #0AH
LOOP2: MOV A, @R0
MOV @R1, A
DEC R0
DEC R1
DJNZ R2, LOOP2
HERE: SJMP HERE

Output:

4. Implement an assembly language program to "exchange data


blocks of 10.
MOV R0, #20H
MOV R1, #30H
MOV R2, #0AH

EXCHANGE_LOOP:
MOV A, @R0
MOV B, @R1
MOV @R1, A
MOV @R0, B
INC R0
INC R1
DJNZ R2, EXCHANGE_LOOP
HERE: SJMP HERE

Output:

After

You might also like