Upload
nishiya-vijayan
View
219
Download
0
Embed Size (px)
Citation preview
8/4/2019 Fair Record
1/86
EMBEDDED SYSTEMS LAB
Expt. No: 1 BLOCK MOVE
Date: 12/07/11
AIM
To transfer data from memory block 1 to memory block 2.
TOOLS REQUIRED
Vision from Keil for an 8051 microcontroller family.
PROCEDURE
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 1 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
2/86
EMBEDDED SYSTEMS LAB
ALGORITHM
No
Yes
DEPARTMENT OF ECE 2 SNGCE, KADAYIRUPPU
IsCounter
= 0?
Initialize source blockPointer
Start
StopDecrement counter
Increment both pointers
Move the content from source todestination and clear the source pointer
Initialize destinationBlock pointer
Copy length of block
8/4/2019 Fair Record
3/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
SJMP 30H
ORG 30H
MOV R0, #35H
MOV R1, #45H
MOV A,@R0
MOV R3, A
INC R0
BACK: MOV A,@R0
MOV @R1, A
MOV @R0,#00H
INC R0
INC R1
DJNZ R3, BACK
DEPARTMENT OF ECE 3 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
4/86
EMBEDDED SYSTEMS LAB
SJMP $
END
RESULT WINDOW
Input Window:
Output Window:
RESULT:
An assembly program to move a block data bytes to internal memory location
has been executed and the output has been verifed.
Expt. No: 2 EXCHANGE OF FIVE BYTES OF DATA
Date: 12/07/11
AIM
To exchange five bytes of data between two internal memory locations.
TOOLS REQUIRED
Vision from Keil for an 8051 microcontroller family
PROCEDURE
1. Create a project in Vision.
DEPARTMENT OF ECE 4 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
5/86
EMBEDDED SYSTEMS LAB
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
ALGORITHM
DEPARTMENT OF ECE 5 SNGCE, KADAYIRUPPU
Initialize source blockPointer
Start
Initialize destinationBlock pointer
Copy length of block
8/4/2019 Fair Record
6/86
EMBEDDED SYSTEMS LAB
No
Yes
PROGRAM
ORG 0000H
MOV R0, #20H
DEPARTMENT OF ECE 6 SNGCE, KADAYIRUPPU
Is
Counter= 0?
StopDecrement counter
Increment both pointers
Exchange content ofSource and destination
Memory location
8/4/2019 Fair Record
7/86
EMBEDDED SYSTEMS LAB
MOV R1, #30H
MOV R3, #05H
LOOP: MOV A,@R0
XCH A,@R1
MOV @R0, A
INC R0
INC R1
DJNZ R3, LOOP
HERE: SJMP HERE
END
RESULT WINDOW
Input Window
Output Window
RESULT
DEPARTMENT OF ECE 7 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
8/86
EMBEDDED SYSTEMS LAB
An assembly program to exchange a block five data bytes between two
internal memory location has been executed and the output has been verifed.
Expt. No: 3 MULTIPLICATION OF TWO 8 BIT NUMBERS
Date: 15/7/11
AIM:
To write a program to multiply two 8 bit numbers using 8051c.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 8 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
9/86
EMBEDDED SYSTEMS LAB
ALGORITHM:
Yes
No
No
Yes
DEPARTMENT OF ECE 9 SNGCE, KADAYIRUPPU
Start
Stop
Take the multiplier and multiplicandfrom the location
Mul=Mul+multiplicand using addcinstruction
Take the multiplier as count
Is carry?Increment the register
Is count=0
Store the result
8/4/2019 Fair Record
10/86
EMBEDDED SYSTEMS LAB
PROGRAM
ORG 0000HMOV R0, #50H
CLR A
MOV R1, A
MOV A,@R0
MOV R3, A
INC R0
MOV A,@R0
MOV R4, A
CLR A
BACK: ADD A, R4
JNC CARRY
INC R1
CARRY: DJNZ R3, BACK
INC R0
INC R0
MOV @R0, A
DEC R0
MOV A, R1
MOV @R0, A
HERE: SJMP HERE
END
DEPARTMENT OF ECE 10 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
11/86
EMBEDDED SYSTEMS LAB
RESULT WINDOW:
Input Window:
Output Window:
RESULT
An assembly program to multiplication of two 8 bit numbers has been
executed and the output has been verifed.
DEPARTMENT OF ECE 11 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
12/86
EMBEDDED SYSTEMS LAB
Expt. No:4 SQUARE ROOT OF AN 8 BIT NUMBER
Date: 15/07/11
AIM:
To find the square root of a number.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family
PROCEDURE
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
DEPARTMENT OF ECE 12 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
13/86
EMBEDDED SYSTEMS LAB
9. Observe the result in the destination address through memory window.
ALGORITHM:
YES
Yes
NoNo
Yes
DEPARTMENT OF ECE 13 SNGCE, KADAYIRUPPU
Start
Set count to 0
Copy number from memory location
Subtract the number with odd number
Increment count on each subtraction
Is result=0
Is result=negativeStore count value to memory
location
Write FF to memory location
8/4/2019 Fair Record
14/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
SJMP 30H
ORG 30H
MOV R0,#50H
MOV A,@R0
MOV R1,#01H
MOV R2,#00H
BACK: SUBB A, R1
INC R2
JZ HERE
JC HERE1
INC R1
INC R1
SJMP BACK
HERE: INC R0
MOV A,R2
MOV @R0,A
DEPARTMENT OF ECE 14 SNGCE, KADAYIRUPPU
Stop
8/4/2019 Fair Record
15/86
EMBEDDED SYSTEMS LAB
SJMP $
HERE1:INC R0
MOV @R0,#0FFH
END
RESULT WINDOW:
Input Window:
Output Window:
RESULT:
An assembly program to find the square root of a number has been executed
and the output has been verifed.
DEPARTMENT OF ECE 15 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
16/86
EMBEDDED SYSTEMS LAB
Expt. No:5 SQUARE OF AN 8 BIT NUMBER
Date: 15/07/11
AIM:
To write a program to find the square of a number.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family
PROCEDURE
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
DEPARTMENT OF ECE 16 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
17/86
EMBEDDED SYSTEMS LAB
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
ALGORITHM:
YES
No
Yes
DEPARTMENT OF ECE 17 SNGCE, KADAYIRUPPU
Start
Copy number from memory location
Set count =number
add the number with next odd number
Decrement the count
Is count=0
Store the result
Stop
Increment by 2
8/4/2019 Fair Record
18/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
MOV R0, #50H
MOV A,@R0
MOV R2, A
MOV R1, #01H
CLR A
LOOP: ADDC A,R1
INC R1
INC R1
DJNZ R2, LOOP
INC R0
MOV @R0, A
HERE: SJMP HERE
DEPARTMENT OF ECE 18 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
19/86
EMBEDDED SYSTEMS LAB
END
RESULT WINDOW:
Input Window:
Output Window:
RESULT:
An assembly program to find the square number has been executed and theoutput has been verifed.
DEPARTMENT OF ECE 19 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
20/86
EMBEDDED SYSTEMS LAB
Expt. No: 6 WAVE FORM GENERATION
Date: 19/07/11
AIM:
To write a program to generate the following waveform
1. sine wave,
2. Square wave,3. Staircase wave.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
DEPARTMENT OF ECE 20 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
21/86
EMBEDDED SYSTEMS LAB
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Open the Logic Analyzer window
8. Load Setup values into the respective port
9. Run the program.
10. Observe the result in the logic analyzer window.
ALGORITHM:
1. SINE WAVE
Angle Sin(angle) VOUT=5V+(5Sin(angle)) CORRESPONDINGDECIMAL TO DAC
VALUE=VOUT*25.6
0 0 5 128
30 0.5 7.5 192
60 0.866 9.33 238
90 1.0 10 255
DEPARTMENT OF ECE 21 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
22/86
EMBEDDED SYSTEMS LAB
120 0.866 9.33 238
150 0.5 7.5 192
180 0 5 128
210 -0.5 2.5 64
240 -0.866 .669 17270 -1.0 0 0
300 -.866 .669 17
330 -0.5 2.5 64
360 0 5 128
2. SQUARE WAVE
Delay Calculation:
Required frequency = 49.99Hz with 50% duty-cycle =>
ON/OFF period = 10.002ms
Delay calculation:
Effective clock frequency = 24MHz/12 = 2MHz => 0.5 S
Delay = 10.002ms => Count = (10.002 x 10 -3 ) / (0.5 x 10-6 ) = 20004
TH1:TL1 = 0xB1DCh
3. STAIRCASE
Step Size: 0xFF/5 = 0x33h/51d
Delay calculation:
Effective clock frequency = 24MHz/12 = 2MHz => 0.5 S
Delay1 = 10ms = 10/5x 10-3 S => Count = (2 x 10-3 ) / (0.5 x 10-6 ) = 20000
TH1:TL1 = E0C0h
Delay2 = .0005ms = 5 x 10-4 S => Count = (5 x 10-4) / (0.5 x 10-6 ) = 1000
TH0:TL0 = FC18h
DEPARTMENT OF ECE 22 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
23/86
EMBEDDED SYSTEMS LAB
1. SINE WAVE
DEPARTMENT OF ECE 23 SNGCE, KADAYIRUPPU
Load P1 with the new level
Decrement count
No
Yes
Define the lookup table partof the code space
Start
Initialize the samples count
Count = 0?
Get the next level from table
Stop
8/4/2019 Fair Record
24/86
EMBEDDED SYSTEMS LAB
2. SQUARE WAVE:
DEPARTMENT OF ECE 24 SNGCE, KADAYIRUPPU
Start
Clear ACC and load P2
Call DELAY2:Load TL0, TH0
Start Timer0: set TR0
NO
YES
Clear TR0, TF0
Add #33h and load P2Configure TMOD register
Call DELAY1:Load TL1, TH1
Start Timer1: set TR1
Clear TR1, TF1TF0 =1?
TF1 =
1?
A =0xFF?
YES
NO
YES NO
8/4/2019 Fair Record
25/86
EMBEDDED SYSTEMS LAB
3.STAIRCASE WAVE:
DEPARTMENT OF ECE 25 SNGCE, KADAYIRUPPU
Start
Clear ACC and load P2.3
Call DELAY:Load TL1, TH1
Start Timer0: set TR1
NO
YES
Clear TR1, TF1
Toggle P2.3
Configure TMOD register
TF1 =1?
8/4/2019 Fair Record
26/86
EMBEDDED SYSTEMS LAB
PROGRAM:
1.SINE WAVE
ORG 0000H
AGAIN: MOV DPTR, #TABLE
MOV R2, #0CH
BACK: CLR A
MOVC A,@A+DPTR
MOV P1, A
INC DPTR
DJNZ R2, BACK
SJMP AGAIN
ORG 300H
TABLE: DB 128,192,238,255,238,192
DB 128,64,17,0,17,64,128
END
2. SQUARE WAVE
ORG 0000H
MOV TMOD, #20H
AGAIN: MOV TL1, #0DCH
MOV TH1, #0B1H
SETB TR1
BACK :JNB TF1, BACK
CLR TR1
DEPARTMENT OF ECE 26 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
27/86
EMBEDDED SYSTEMS LAB
CPL P2.3
CLR TF1
SJMP AGAIN
END
3.STAIRCASE WAVE:
ORG 0000H
MOV TMOD, #10H
AGAIN: CLR A
MOV P2, A
ACALL DELAY1
LOOP: ADD A, #33H
MOV P2, A
ACALL DELAY1
CJNE A, #0FFH, LOOP
SJMP AGAIN
DELAY1: MOV TL1,#0C0H
MOV TH1,#0E0H
SETB TR1
BACK: JNB TF1,BACK
CLR TR1
CLR TF1
RET
DELAY2:MOV TL0, #18H
DEPARTMENT OF ECE 27 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
28/86
EMBEDDED SYSTEMS LAB
MOV TH0,#0FCH
SETB TR0
BACK1: JNB TF1, BACK1
CLR TR0
CLR TF0
RET
END
RESULT WINDOW:
SINE WAVE
SQUARE WAVE
DEPARTMENT OF ECE 28 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
29/86
8/4/2019 Fair Record
30/86
EMBEDDED SYSTEMS LAB
Expt. No:7 SORTING OF NUMBERS
Date: 19/7/11
AIM:
To arrange a block of data in descending order.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 30 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
31/86
EMBEDDED SYSTEMS LAB
ALGORITHM:
No
Yes
No
DEPARTMENT OF ECE 31 SNGCE, KADAYIRUPPU
Yes
No
Copy length of block
Initialize outer counter
Initialize inner counter
Compare two numbers
Exchange two numbers
Decrement inner counter
Decrement outer counter
Is counter=0?
Is counter=0?
Is carry flag
set?
Increment memorypointers
Initialize memory pointers
Start
8/4/2019 Fair Record
32/86
EMBEDDED SYSTEMS LAB
No
PROGRAM:
ORG 0000H
MOV R0, #50H
MOV R1, #60H
MOV R3, #0AH
BACK1: MOV A,@R0
MOV A,@R0
MOV @R1, A
INC R0
INC R1
DJNZ R3, BACK1
LOOP: MOV R3, #0AH
MOV R4, #0AH
MOV R0, #60H
BACK: MOV A,@R0
MOV B, A
INC R0
MOV A,@R0
CJNE A, B, LOOP1
LOOP1: JC LOOP2
MOV A,@R0
DEC R0
XCH A,@R0
INC R0
MOV @R0, A
LOOP2: DJNZ R3,BACK
DJNZ R4, LOOP
DEPARTMENT OF ECE 32 SNGCE, KADAYIRUPPU
Stop
8/4/2019 Fair Record
33/86
EMBEDDED SYSTEMS LAB
HERE: SJMP HERE
END
RESULT WINDOW:
Input Window:
Output Window:
RESULT:
An assembly program to sort 10 numbers has been executed and the output
has been verifed.
DEPARTMENT OF ECE 33 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
34/86
EMBEDDED SYSTEMS LAB
Expt. No: 8 PALINDROME
Date: 22/07/11
AIM:
To check the given data is palindrome or not.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family
PROCEDURE
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window
DEPARTMENT OF ECE 34 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
35/86
EMBEDDED SYSTEMS LAB
ALGORITHM
No
Yes
No
No
Yes
DEPARTMENT OF ECE 35 SNGCE, KADAYIRUPPU
IsCounter
= 0?
Initialize source blockPointer
Decrement counter
Increment both pointers
Move the content from source todestination
Initialize destinationBlock pointer
Copy length of block
Reload thecounter
Compare the first bytes from 2 locations
Is equal?
IsCounter
= 0?
Start
8/4/2019 Fair Record
36/86
EMBEDDED SYSTEMS LAB
Yes
PROGRAM:
ORG 0000H
MOV R3, #09H
MOV R0, #20H
MOV R7, #00H
MOV DPTR, #MYDATA
LOOP: CLR A
MOVC A,@A+DPTR
MOV @R0, A
INC R0
INC DPTR
DJNZ R3, LOOP
MOV R3, #09H
MOV R1, #40H
MOV R0, #28H
LOOP1: MOV A,@R0
MOV @R1, A
DEC R0
INC R1
DJNZ R3, LOOP1
MOV R3, #09H
MOV R0, #20H
MOV R1, #40H
CLR C
DEPARTMENT OF ECE 36 SNGCE, KADAYIRUPPU
Store FF to memory location
Decrement counter
Store 11 to memory
Stop
8/4/2019 Fair Record
37/86
EMBEDDED SYSTEMS LAB
LOOP3: CLR C
MOV A,@R1
SUBB A,@R0
CJNE A, #00H, LOOP4
INC R0
INC R1
DJNZ R3, LOOP3
MOV R6, #11H
MOV R1, #60H
MOV A, R6
MOV @R1, A
SJMP HERE
LOOP4: MOV R6, #0FFH
MOV R1, #30H
MOV A, R6
MOV @R1, A
HERE: SJMP HERE
ORG 80H
MYDATA: DB "AABBCBBAG"
END
RESULT WINDOW:
Input Window:
Output Window:
DEPARTMENT OF ECE 37 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
38/86
EMBEDDED SYSTEMS LAB
RESULT
An assembly program to check a given string is palindrome has been executed and
the output has been verified.
DEPARTMENT OF ECE 38 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
39/86
8/4/2019 Fair Record
40/86
EMBEDDED SYSTEMS LAB
ALGORITHM
No
Yes
DEPARTMENT OF ECE 40 SNGCE, KADAYIRUPPU
Take no. from memory location
Is count==no
Start
Stop
Cube=Square*number
Take it as count
Get first odd no.
Square =0
Square=square + odd no
Increment by 2 to obtain next odd
8/4/2019 Fair Record
41/86
8/4/2019 Fair Record
42/86
EMBEDDED SYSTEMS LAB
Output Window:
RESULT:
An assembly program to find the cube of a number has been executed and
the output has been verifed.
DEPARTMENT OF ECE 42 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
43/86
EMBEDDED SYSTEMS LAB
Expt. No: 10 COPY THE MESSAGE FROM
Date: 26/07/11 ROM TO RAM
AIM:
To copy the message WELCOME from ROM to RAM.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 43 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
44/86
8/4/2019 Fair Record
45/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
MOV R3,#07H
MOV R0,#20H
MOV DPTR,#MYDATA
LOOP:CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC R0
INC DPTR
DJNZ R3,LOOP
SJMP $
ORG 30H
MYDATA: DB"WELCOME"
RESULT WINDOW:
Input Window:
Output Window:
DEPARTMENT OF ECE 45 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
46/86
EMBEDDED SYSTEMS LAB
RESULT:
An assembly program to copy the message WELCOME from ROM to RAM
has been executed and the output has been verifed
Expt. No: 11 ADDITION OF TWO 16-BIT NUMBERS
Date: 26/07/11
AIM:
To perform addition of two 16-bit numbers
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
DEPARTMENT OF ECE 46 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
47/86
EMBEDDED SYSTEMS LAB
8. Run the program.
9. Observe the result in the destination address through memory window.
ALGORITHM:
DEPARTMENT OF ECE 47 SNGCE, KADAYIRUPPU
Start
Stop
Add MSBs With carry and store itin next location
Add LSBs and store it in nextmemory location
Copy LSB of second no.andincrement pointer
Copy MSB of first no.andincrement pointer
Copy LSB first no and incrementpointer
Load DPTR with memory location
Copy MSB of second no.andincrement pointer
Is carry?Increment location and store carry
8/4/2019 Fair Record
48/86
8/4/2019 Fair Record
49/86
8/4/2019 Fair Record
50/86
8/4/2019 Fair Record
51/86
EMBEDDED SYSTEMS LAB
Expt. No: 12 SUM OF 5 BCD NUMBERS
Date: 26/07/11
AIM:
To find sum of 5 BCD numbers.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 51 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
52/86
EMBEDDED SYSTEMS LAB
ALGORITHM:
Yes
No
No
DEPARTMENT OF ECE 52 SNGCE, KADAYIRUPPU
Load the limit frommemory location
Load numbers frommemory location
Clear Sum and Carry
Add Sum with the content ofthe memory location
Add 0110 to nibble that havevalue >1001
Increment carry
Increment memory location
Decrement limit
If limit=0
Display output
If carry=0
Decrement limit
Stop
Start
8/4/2019 Fair Record
53/86
8/4/2019 Fair Record
54/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
MOV R0, #50H
MOV R1, #60H
MOV R2, #5H
CLR A
MOV B, A
AGAIN:ADD A,@R0
DA A
JNC NEXT
INC B
NEXT: INC R0
DJNZ R2, AGAIN
MOV @R1, B
INC R1
MOV @R1, A
HERE: SJMP HERE
END
RESULT WINDOW:
Input Window:
Output Window:
DEPARTMENT OF ECE 54 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
55/86
EMBEDDED SYSTEMS LAB
RESULT:
An assembly program to find sum of BCD numbers was executed
successfully.
DEPARTMENT OF ECE 55 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
56/86
EMBEDDED SYSTEMS LAB
Expt. No: 13 CONVERSION PACKED BCD TO ASCII
Date: 30/07/11
AIM:
To implement packed BCD to ASCII conversion.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window
DEPARTMENT OF ECE 56 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
57/86
8/4/2019 Fair Record
58/86
8/4/2019 Fair Record
59/86
8/4/2019 Fair Record
60/86
8/4/2019 Fair Record
61/86
EMBEDDED SYSTEMS LAB
ALGORITHM:
YES
No
Yes
DEPARTMENT OF ECE 61 SNGCE, KADAYIRUPPU
Copy count from memory location
Increment location
Copy number from memory location
Unpack number and separate MSB & LSB
Add 30 with LSB & MSB
Store result in memory location
Decrement count
Stop
Is count=0?
Start
8/4/2019 Fair Record
62/86
8/4/2019 Fair Record
63/86
8/4/2019 Fair Record
64/86
8/4/2019 Fair Record
65/86
EMBEDDED SYSTEMS LAB
PROGRAM
DEPARTMENT OF ECE 65 SNGCE, KADAYIRUPPU
Start
Enter the count
Copy the number frommemory location
Multiply it by 0FH and swapit to get the MSB
Copy the next number frommemory location
Multiply it by 0FH to get theLSB
Store the result in the memory
location
Increment the memorylocation and decrement thecount
Ifcount=0
Stop
Add the MSB and LSB to getthe BCD number
8/4/2019 Fair Record
66/86
8/4/2019 Fair Record
67/86
8/4/2019 Fair Record
68/86
8/4/2019 Fair Record
69/86
EMBEDDED SYSTEMS LAB
Expt. No: 16 CHECKSUM
Date: 2/08/11
AIM:
To write a program to find the checksum of given data HELLO.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Enter the data values in the source address through memory window.
8. Run the program.
9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE 69 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
70/86
EMBEDDED SYSTEMS LAB
PROGRAM:
No
Yes
DEPARTMENT OF ECE 70 SNGCE, KADAYIRUPPU
STOP
Start
Exchange contents of source anddestination
Initialize destination block pointer
Initialize source block pointer
Input string
Store data
Twos compliment
Add hex value of string
Is counter=0
8/4/2019 Fair Record
71/86
8/4/2019 Fair Record
72/86
EMBEDDED SYSTEMS LAB
Input window:
Output Window:
RESULT:
An assembly program to find the checksum of given data HELLO has been
executed and the output has been verifed.
DEPARTMENT OF ECE 72 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
73/86
EMBEDDED SYSTEMS LAB
Expt. No: 17 TRANSPOSE OF A MATRIX
Date: 2/08/11
AIM:
To generate transpose of a matrix of arbitrary size.
TOOLS REQUIRED:
Vision from Keil for an 8051 microcontroller family.
PROCEDURE:
1. Create a project in Vision.
2. Set the device to AT89C51.
3. The source code is written in the text window and is saved as .asm file.
4. Add the source file into the Source Group.
5. Build target.
6. Start the debug session.
7. Run the program.
8. Observe the result in the memory window.
DEPARTMENT OF ECE 73 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
74/86
8/4/2019 Fair Record
75/86
8/4/2019 Fair Record
76/86
8/4/2019 Fair Record
77/86
EMBEDDED SYSTEMS LAB
Output Window:
RESULT:
An assembly program to generate transpose of a matrix hs been executed and the
results verified in the memory window.
DEPARTMENT OF ECE 77 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
78/86
8/4/2019 Fair Record
79/86
EMBEDDED SYSTEMS LAB
ALGORITHM:
Yes
No
Yes
No
Yes
No Yes
No
DEPARTMENT OF ECE 79 SNGCE, KADAYIRUPPU
Start
Load the memory location
Increment the location and store the result
Increment location and copy second no.
Copy first operand
Increment location
Load choice from that location
Is choice=3
Is choice=4
Is choice=2
Is choice=1
Stop
Div=A/B
Mul=A*B
Sub=A-B
Sum=A+B
1
1
1
1
1
8/4/2019 Fair Record
80/86
8/4/2019 Fair Record
81/86
EMBEDDED SYSTEMS LAB
MOV @R0,A
SJMP HERE
LOOP2: CJNE R3,#03H,LOOP3
MOV B, A
MOV A, R4
MUL AB
INC R0
MOV @R0, A
SJMP HERE
LOOP3: CJNE R3,#04H,LOOP4
MOV B, A
MOV A, R4
DIV AB
INC R0
MOV @R0, A
INC R0
MOV A, B
MOV @R0, A
SJMP HERE
LOOP4: MOV A, #0FFH
INC R0
MOV @R0, A
HERE: SJMP HERE
END
RESULT WINDOW:
Input Window:
DEPARTMENT OF ECE 81 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
82/86
EMBEDDED SYSTEMS LAB
Output Window:
RESULT:
An assembly program to impliment calculator has been executed and the
output has been verifed.
Expt. No:19 FIBONACCI SERIES
DEPARTMENT OF ECE 82 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
83/86
8/4/2019 Fair Record
84/86
8/4/2019 Fair Record
85/86
EMBEDDED SYSTEMS LAB
PROGRAM:
ORG 0000H
CLR A
MOV R3, 50H
MOV R0, #51H
MOV @R0, #00H
INC R0
MOV @R0, #01H
MOV R1, #01H
DEC R3
DEC R3
LOOP: ADD A, R1
INC R0
MOV @R0, A
MOV R1, A
DEC R0
MOV A,@R0
INC R0
DJNZ R3, LOOP
HERE: SJMP HERE
END
RESULT WINDOW:
Input window:
DEPARTMENT OF ECE 85 SNGCE, KADAYIRUPPU
8/4/2019 Fair Record
86/86
EMBEDDED SYSTEMS LAB
Output Window:
RESULT:
An assembly program to generate Fibonacci series of 10 elements has been
written, executed and the output has been verifed.