Assignment - 4 Name:-Krishna Sah Group:-CS-B1 Reg No:-20194190
Assignment - 4 Name:-Krishna Sah Group:-CS-B1 Reg No:-20194190
Name:-Krishna Sah
Group:-CS-B1
Reg No:-20194190
Keil Embedded C:
MAIN: MOV R2,#3; Loading the number to be checked whether it's a prime or
not
LABEL5: MOV A,R2
MOV B,#02
DIV AB ;Dividing the number by 2
MOV R0,A
CJNE R0,#01H,LABEL2 ;Checking whether the number is 2
SETB C
SJMP LABEL4
LABEL1: DEC R0 ; decrementing and checking whether the number is not
divisible by all possible values of number/2
CJNE R0,#01H,LABEL2
SETB C ; setting the carry flag to 1 if it is a prime number
SJMP LABEL4
LABEL2: MOV A,R2
MOV B,R0
DIV AB
MOV R3,B
CJNE R3,#0H,LABEL1
CLR C ; setting the carry flag to 0 if it not a prime number
LABEL4:
END
Q2. Move a block of data from one memory location to another where memory
is addressed through indirect mode in both overlapping and non overlapping
cases.
NON-OVERLAPPING
MOV A,@R0
MOV @R1,A
INC R1
INC R0
DJNZ R2, loop
END
OVERLAPPING
MOV A,@R1
MOV @R0,A
DEC R1
DEC R0
DJNZ R2, loop
END
Q3. Write an assembly language program to transfer N = ___ bytes of data
from location
A: _______H to location B: _______H.
Where, N, A and B are: N = 05H, A: 30H B: 40H
MOV A,@R0
MOV @R1,A
INC R1
INC R0
DJNZ R2, loop
END
Q4. Write an assembly language program to exchange 05H bytes of data at
location 30H and 40H.
MOV A,@R0
MOV R3,A
MOV A,@R1
MOV @R0,A
MOV A,R3
MOV @R1,A
INC R1
INC R0
DJNZ R2, loop
END