0% found this document useful (0 votes)
20 views23 pages

Embedded System Journal

The document outlines several practical exercises using the DYNA-8051 Trainer Kit, focusing on programming tasks such as addition of 8-bit and 16-bit numbers, nibble separation of 8-bit and 16-bit numbers, and sorting numbers in descending order. Each practical includes a theory section, algorithm, results before and after execution, and assembly code. The exercises aim to familiarize users with basic operations and programming concepts in assembly language.

Uploaded by

rinatanvar450
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)
20 views23 pages

Embedded System Journal

The document outlines several practical exercises using the DYNA-8051 Trainer Kit, focusing on programming tasks such as addition of 8-bit and 16-bit numbers, nibble separation of 8-bit and 16-bit numbers, and sorting numbers in descending order. Each practical includes a theory section, algorithm, results before and after execution, and assembly code. The exercises aim to familiarize users with basic operations and programming concepts in assembly language.

Uploaded by

rinatanvar450
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/ 23

Practical No.

1
Aim: Write a program to perform Addition of two 8 bits numbers.
Theory: The program's objective is to perform the addition of two 8-bit numbers using the
DYNA-8051 Trainer Kit. The given algorithm outlines the steps involved in achieving this task.
It initializes registers, fetches numbers from memory, performs additions, checks for carry,
increments registers as needed, and stores the final result in memory. The program stops after
completing the addition process.

Requirement: DYNA-8051 Trainer Kit

Algorithm:
1) Initialize RI with 00
2) Initialize DPTR with C100
3) Move content pointed by location in DPTR to Reg A
4) Move content of A to R2
5) Increment DPTR
6) Move content pointed by location in DPTR to Reg A
7) Add content of A and R2
8) Move contents of A to R2
9) Increment DPTR
10) Check for carry, if no carry go to step no. 12
11) If cary increment R
12) Move content of RI to A
13)Move content of A to location posted by DPTR 3
14) Move R2 to A
15) Incremem DPTR
16) Move content of A to location pointed by DPTR
17) Stop.

Result:

Before Execution After Execution


Memory Address Data
Memory Address Data
C100
C100
C101
C101
C103 Result
C102
C104 Carry C103
C104
Code:
Memory Address Label Instruction Opcode

C000 MOV R, #00

C001

C002 MOV DPTR, #CIOD H

C003

C004

C005 MOV A, @ DPTR

C006 MOV R2, A

C007 INC DPTR

C008 MOVX A, @DPTR

C009 ADD A, R2

C00A MOV R2, A

C00B INC DPTR

C00C JNC NEXT

C00D

C00E INC R1

C00F NEXT MOV A, R1

C010 MOV X @ DPTR

C011 MOV A, R2

C012 INC DPTR

C013 MOV X @ DPTR A

C014 RET
Practical No. 2
Aim: Write a program to perform Addition of two 16 bits numbers.
Theory: The program aims to add two 16-bit numbers using the DYNA-8051 Trainer Kit. It
follows a step-by-step algorithm to accomplish this task. The program initializes registers,
fetches numbers from memory, performs additions, checks for carry, increments registers or
memory pointers accordingly, and finally stores the result in memory. The program terminates
once the addition process is complete.

Requirement: DYNA-8051 Trainer Kit


Algorithm:
1) Initialize RO with 00
2) Clear carry flag
3) Initialize R7 with 00
4) Initialize DPTR with D000
5) Move the content pointed by DPTR to A
6) Move content of A to R1
7) Increment DPTR
8) Move the content pointed by DPTR to Acc
9) Move content of acc to R2
10) Increment DPTR
11) Move the content pointed by DPTR to Acc
12) Move content of acc to R3
13) Increment DPTR
14) Move the content pointed by DPTR to Acc
15) Move content of acc to R4
16) Move content of RI to Acc
17) Add the content of Acc with R3
18) Move content of A to R5
19) Move content of R2 to Acc
20) Add content of Acc with R4 along with carry
21) Move content of Acc to R6
22) Check for carry if carry increment R7
23) Else increment DPTR
24) Move content of R7 to A
25) Move the content of Acc to current DPTR location
26) Increment DPTR
27) Move content of R6 to A
28) Move the content of Acc to current DPTR location
29) Increment DPTR
30) Move content of R5 to A
31) Move the content of Acc to current DPTR location
32) Stop

Result:

Before Execution After Execution

Memory Address Data Memory Address Data

D000 D000

D001 D001

D002 D002

D003 D003

D004 Result LSB D004

D005 Result MSB D005

D006 Result D006


Carry
Code

Memory Address Label Instruction Opcode

C000 CLR C

C001 MOV R7, # 00

C002

C003 MOV DPTR, # DOOO

C004

C005

C006 MOVX A, @ DPTR

C007 MOV R1, A

C008 INC DPTR

C009 MOVX A, @DPTR

C00A MOV R2, A

C00B INC DPTR

C00C MOVX A, @ DPTR

C00D MOV R3, A

C00E INC DPTR

C00F MOV A, @DPTR

C010 MOV Ru, A

C011 MOV A, R1

C012 ADD A, R3

C013 MOV R5, A

C014 MOV A, R2
C015 ADDC A, R4
C016 MOV R6, A
C017 JNC HERE
C018
C019 INC R7
C01A HERE : INC DPTR
C01B MOV A, R7
C01C MOV X @ DPTR, A
C01D INC DPTR
C01E MOV A, R6
C01F MOVX @ DPTR, A
C020 INC DPTR
C021 MOV A, R6
C022 MOVX @ DPTR, A
C023 RET
Practical No. 3
Aim: Write a program to perform nibble separation of a 8 bit number.
Requirement: DYNA-8051 Trainer Kit

Theory: The program aims to perform nibble separation of an 8-bit number. It initializes
registers, retrieves the 8-bit number from memory, performs bitwise operations to extract the
high and low nibbles, and stores them in separate registers. The program then terminates.

Algorithm:
1) Load the 8-bit number in accumulator.
2) Move contents of accumulator to R2.
3) AND contents of accumulator with OFOH.
4) Swap the contents of accumulator.
5) Move contents of accumulator to Ro
6) Move contents of R₂ to accumulator
7) AND contents of accumulator with OFH.
8) Move contents of accumulator to R
9) Stop.

Result:

Before Execution After Execution

Register Data Register Data

R1
Accumulator 92H
R2 92H
Code:

Memory Address Label Instruction Opcode

C000 START MOV A, #92H

C001

C002 MOV R2, A

C003

C004 ANL A, #0F0H

C005

C006 SWAP A

C007 MOV R3, A

C008

C009 MOV A, R2

C00A

C00B LOOP ANL A, #0FH

C00C

C00D MOV R1, A

C00E

C00F MOV A, R2

C010

C011 MOV R2, A

C012

C013 RET
Practical No. 4
Aim: Write a program to perform nibble separation of a 16 bit number.
Requirement: DYNA-8051 Trainer Kit

Theory: The program aims to perform nibble separation of a 16-bit number. It follows a step-
by-step algorithm to accomplish this task. The program initializes registers, retrieves the 16-bit
number from external memory, performs bitwise operations to extract the high and low nibbles
of each byte, and stores them in separate registers. The program then terminates.

Algorithm:
1) Initialize register R7 with 00H.
2) Load the value DO00H into the DPTR register.
3) Read the value at the memory location pointed by DPTR and store it in the accumulator.
4) Move the value from the accumulator to register R1.
5) Increment DPTR to point to the next memory location.
6) Read the value at the updated memory location pointed by DPTR and store it in the
accumulator.
7) Move the value from the accumulator to register R2.
8) Read the value at the next memory location pointed by DPTR using MOVX instruction
and store it in the accumulator.
9) Move the value from the accumulator to register R3.
10) Increment DPTR to point to the next memory location.
11) Read the value at the updated memory location pointed by DPTR using MOVX
instruction and store it in the accumulator.
12) Move the value from the accumulator to register R4.
13) Add the values in registers R1 and R3 using the ADD instruction and store the result in
the accumulator.
14) Move the value from the accumulator to register R5.
15) Add the values in registers R2 and R4, along with the carry flag, using the ADC
instruction and store the result in the accumulator.
16) Move the value from the accumulator to register R6.
17) Check if there was no carry generated during the addition operation using the JNC
instruction.
18) If there was no carry, increment register R7.
19) Move the value from register R7 to the accumulator.
20) Increment DPTR to point to the next memory location.
21) Move the value from the accumulator to the memory location pointed by DPTR.
22) Increment DPTR to point to the next memory location.
23) Move the value from register R5 to the accumulator.
24) Move the value from the accumulator to the memory location pointed by DPTR.
25) Check if there was no carry generated during the addition operation using the JNC
instruction.
26) If there was no carry, move the value from register R6 to the accumulator.
27) Move the value from the accumulator to the memory location pointed by DPTR.
28) Return from the subroutine

Result:

Before Execution After Execution

Register Data Register Data

R7 00H R7 01H
DPTR D000H DPTR D002H
Accumulator Accumulator
R0
R0
R1 D000H
R1
R2 D001H
R2 R3 D002H
R3 R4 D003H
R4 R5
R5 R6
R6
Code:

Memory Address Label Instruction Opcode

C000 START MOV R7, #00H

C001 MOV DPTR, #D000H

C002

C003

C004

C005 MOVX A, @DPTR

C006 MOV R1, A

C007

C008 INC DPTR

C009 MOVX A, @DPTR

C00A MOV R2, A

C00B

C00C MOVX A, @ DPTR

C00D MOV R3, A

C00E

C00F

C010 MOV A, @DPTR

C011 MOV R4, A


C012

C013

C014

C015 ADD A, R3
C016
C017 MOV R5, A
C018
C019 MOV A, R2
C01A
C01B ADC A, R4
C01C
C01D MOV R6, A
C01E
C01F JNC Next
C020
C021
C022 NEXT INC R7
C023 MOV A, R7
C024
C025 INC DPTR
C026 MOVX @DPTR, A
C027 INC DPTR
C028 MOV A, R5
C029
C02A MOVX @DPTR, A
C02B JNC Next2
C02C
C02D
C02E Next2 MOV A, R6
C02F
C030 MOVX @DPTR, A
C031 RET
Practical No. 5
Aim: Write a program to sort numbers in descending order
Requirement: DYNA-8051 Kit
Algorithm:
1) Initialize the number of elements counter
2) Initialize the number of comparison counter
3) Compare the elements. If first element > second element, go to step 8 else go to step 4
4) Swap the elements
5) Decrement the comparison counter
6) Is count=0? If yes, go to step 8 else go to step 4
7) Insert the number in proper position
8) Increment the elements counter
9) Is count=N? Is yes, go to step 11 else go to step 2
10) Store the result
11) Stop.
Theory: The program's objective is to arrange a set of numbers in descending order using the
DYNA-8051 Kit. It begins by initializing the counters for the number of elements and
comparisons. It then compares the elements and swaps them if necessary to ensure the largest
element is in the proper position. The comparison counter is decremented, and the process
repeats until all elements have been compared and arranged. Finally, the sorted result is stored,
and the program terminates

Result:
Before Execution After Execution

Register Data Register Data

Accumulator DPTR DPTR


R5 A
DPTR D000H
R6 A
R5 R7 A
R6
R7
Code:

Memory Address Label Instruction Opcode

C000 START MOV R7, #00H

C001 MOV DPTR, #D000H

C002

C003

C004

C005 MOVX A, @DPTR

C006 MOV R1, A

C007

C008 INC DPTR

C009 MOVX A, @DPTR

C00A MOV R2, A

C00B

C00C MOVX A, @ DPTR

C00D MOV R3, A

C00E

C00F

C010 MOV A, @DPTR

C011 MOV R4, A


C012

C013

C014

C015 ADD A, R3
C016
C017 MOV R5, A
C018
C019 MOV A, R2
C01A
C01B ADC A, R4
C01C
C01D MOV R6, A
C01E
C01F JNC Next
C020
C021
C022 NEXT INC R7
C023 MOV A, R7
C024
C025 INC DPTR
C026 MOVX @DPTR, A
C027 INC DPTR
C028 MOV A, R5
C029
C02A MOVX @DPTR, A
C02B JNC Next2
C02C
C02D
C02E Next2 MOV A, R6
C02F
C030 MOVX @DPTR, A
C031 RET
Practical No. 6
Aim: Write a program to sort numbers in ascending order
Requirement: DYNA-8051 Kit
Algorithm:
1) Initialize the number of elements counter
2) Initialize the number of comparison counter
3) Compare the elements. If first element < second element, go to step 8 else go to step 4
4) Swap the elements
5) Decrement the comparison counter
6) Is count=0? If yes, go to step 8 else go to step 4
7) Insert the number in proper position
8) Increment the elements counter
9) Is count=N? Is yes, go to step 11 else go to step 2
10) Store the result
11) Stop.

Theory: The program's objective is to sort numbers in ascending order using the DYNA-8051
Kit. It follows a specific algorithm that involves comparing pairs of elements, swapping them if
necessary, and inserting the numbers in their proper positions. The algorithm uses counters to
keep track of the number of elements and comparisons. The program terminates once the sorting
process is completed.

Result:
Before Execution After Execution

Memory Address Data Memory Address Data


Accumulator DPTR DPTR
DPTR D000H R5 A
R5 R6 A
R6 R7 A
R7
Code :

Memory Address Label Instruction Opcode

MOV DPTR, # D000 H


MOV A, @ DPTR
DEC A
MOV R5, A
MOV R6, A
MOV R7, A
up MOV DPTR, # D001H
Jump MOV A, @ DPTR
MOV R0, A
INT DPTR
MOVX A, @DPTR
CLR C
SUBB A, R0
JNC Here

MOV A, @DPTR
DEC DPL
MOVX @ DPTR, A
MOV A, R0
INT DPTR
MOVX @ DPTR, A
Here DJNZ R6, Jump
MOV A, R5
MOV R6, A
DJNZ R7, up
RET
MOV DPTR, # D000 H
MOVX A, @ DPTR
DEC A
MOV R5, A
MOV R6, A
MOV R7, A
C008 Up MOV DPTR, # D000 H
C00B Jump MOVX A, @ DPTR
MOV R0, A
INC DPTR
MOV A, @DPTR
CLR C
SUBB A, R0
JNC HERE
MOVX @DPTR, A
DEC DPL (82H)
MOVX @DPTR, A
MOV A, R0
INC DPTR
MOVX @DPTR, A
C01A HERE DJNZ R6, JUMP
MOV A, R6
MOV R6, A
DJNZ R7,UP
RET
Practical No. 7
Aim: Write a program for serial addition
Requirement: DYNA-8051 Kit
Algorithm:
1) Initialize counter at D000H
2) Initialize DPTR with D000H
3) Move the content at location of DPTR to Accumulator
4) Move content of Acc to R1
5) Initialize DPTR with D001H
6) Initialize Acc to 0
7) Move content of Acc to R2
8) Move content of Acc to RO
9) Move content of DPTR to Acc
10) Add contents of Acc and RO
11) Check for carry
12) If carry, increment R2
13) Increment DPTR
14) Decrement and jump if R1 not zero to Step 8
15) Move content of Ace to R7
16) Move content of R2 to Ace
17) Move content of Acc to location pointed by DPTR
18) Increment DPTR
19) Move R7 to Acc
20) Move content of Acc to location pointed by DPTR
21) Stop

Theory: The program aims to perform serial addition using the DYNA-8051 Kit.
It follows a specific algorithm to add numbers in a sequential manner. The
algorithm involves initializing registers and memory addresses, retrieving and
manipulating data, performing additions with carry checks, and storing the results
in memory. The program terminates once the addition process is completed.
Result:
Before Execution After Execution

Memory Address Data Memory Address Data

D000 Count __

D000
Code:

Memory Address Label Instruction Opcode

MOV DPTR, # D000 H


MOV A, @ DPTR
MOV R1, A
MOV DPTR, # D001H
MOV A, # 00H
MOV R2, A
Here MOVX R0, A
MOVX A, @DPTR
ADD, A, R0
JNC NEXT
INC R2
NEXT INC DPTR
DJNZ R1 HERE
MOV R7, A

MOV A, R2
MOV X @DPTR, A
INT DPTR
MOV A, R7
MOVX @ DPTR, A
RET

You might also like