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

Embeddedsystem Lab4 Assignment4

The document contains a series of embedded system lab activities involving assembly programming. Each activity includes specific tasks such as toggling bits, transferring data between ports, performing arithmetic operations, manipulating the stack, and using a simulator for step-by-step execution. Code snippets for each activity are provided to illustrate the implementation of the tasks.

Uploaded by

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

Embeddedsystem Lab4 Assignment4

The document contains a series of embedded system lab activities involving assembly programming. Each activity includes specific tasks such as toggling bits, transferring data between ports, performing arithmetic operations, manipulating the stack, and using a simulator for step-by-step execution. Code snippets for each activity are provided to illustrate the implementation of the tasks.

Uploaded by

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

Prashanna Kumar Yadav – 122EC0966

EMBEDDED SYSTEM LAB


LAB 4
Activity -1
Write and assemble a program to toggle all the bits of P0, P1, and P2 continuously
by sending 55H and AAH to these ports. Put a time delay between the "on" and "off"
states. Then using the simulator, single-step through the program and examine the
ports. Do not single-step through the time delay call.

Code :-
ORG 0000H
MAIN:
MOV P0, #55H
MOV P1, #55H
MOV P2, #55H
CALL DELAY
MOV P0, #0AAH
MOV P1, #0AAH
MOV P2, #0AAH
CALL DELAY
SJMP MAIN
DELAY:
MOV R7, #255
L1: MOV R6, #255
L2: DJNZ R6, L2
DJNZ R7, L1
RET
END
ACTIVITY 2
Using a simulator, write a program to get a byte of data from P1 and send it
to P0 and P2. Also, give a copy of it to registers R0, R1, and R2. Single-step
the program and examine the ports and registers.

CODE :-

ORG 00H
MOV A,#08H
MOV P1,A
BACK: MOV A,P1
MOV P0,A
MOV P2,A
MOV R0,A
MOV R1,A
MOV R2,A
SJMP BACK
END
ACTIVITY 3
Write and assemble a program to add the following data and then use the simulator to
examine the CY flag. 92H, 23H, 66H, 87H, F5H

CODE :-
ORG 00H

MAIN:
MOV A,#92H
ADD A,#23H
MOV P1.0, C
ADD A,#66H
MOV P1.0, C
ADD A,#87H
MOV P1.0, C
ADD A,#0F5H
MOV P1.0, C
SJMP MAIN
END
ACTIVITY 4
Write and assemble a program to load values into each of registers R0 - R4
and then push each of these registers onto the stack. Single-step the
program, and examine the stack and the SP register after the execution of
each instruction.

CODE:-
ORG 00H

MAIN:
MOV R0,#10H
MOV R1,#20H
MOV R2,#30H
MOV R3,#40H
MOV R4,#50H
PUSH 0
PUSH 1
PUSH 2
PUSH 3
PUSH 4
SJMP MAIN
END
ACTIVITY 5

Write and assemble a program to: (a) Set SP = 0D, (b) Put a different value in
each of RAM locations 0D, 0C, 0B, 0A, 09, and 08, (c) POP each stack location
into registers R0 - R4. Use the simulator to single-step and examine the
registers, the stack, and the stack pointer.

CODE:-

ORG 00H

MAIN:
MOV SP,#0DH
MOV 0DH,#11H
MOV 0CH,#22H
MOV 0BH,#33H
MOV 0AH,#44H
MOV 09H,#55H
MOV 08H,#66H
POP 0
POP 1
POP 2
POP 3
POP 4

SJMP MAIN
END

You might also like