Beruflich Dokumente
Kultur Dokumente
BLOCK MOVE
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
SNGCE, KADAYIRUPPU
ALGORITHM
Start Copy length of block
Move the content from source to destination and clear the source pointer
No Is Counter = 0? Yes
Decrement counter
Stop
DEPARTMENT OF ECE
SNGCE, KADAYIRUPPU
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
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.
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
SNGCE, KADAYIRUPPU
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
Initialize source block Pointer Initialize destination Block pointer DEPARTMENT OF ECE 5 SNGCE, KADAYIRUPPU
Exchange content of Source and destination Memory location Increment both pointers
No Is Counter = 0? Yes
Decrement counter
Stop
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
Output Window
RESULT
DEPARTMENT OF ECE
SNGCE, KADAYIRUPPU
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.
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
SNGCE, KADAYIRUPPU
ALGORITHM:
Start
Is carry? No
No
DEPARTMENT OF ECE
Stop
SNGCE, KADAYIRUPPU
PROGRAM ORG 0000H MOV 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
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
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
EMBEDDED SYSTEMS LAB 9. Observe the result in the destination address through memory window.
ALGORITHM:
Start
location
location
Yes Is result=0 No No Is result=negative Yes Store count value to memory location
DEPARTMENT OF ECE
13
SNGCE, KADAYIRUPPU
Stop
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
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
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
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:
Start
YES location
No Increment by 2 Is count=0 Yes Store the result DEPARTMENT OF ECE 17 Stop SNGCE, KADAYIRUPPU
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
Output Window:
RESULT: An assembly program to find the square number has been executed and the output has been verifed.
DEPARTMENT OF ECE
19
SNGCE, KADAYIRUPPU
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
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.
Angle
Sin(angle)
VOUT=5V+(5Sin(angle))
0 30 60 90
5 7.5 9.33 10
DEPARTMENT OF ECE
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
1. SINE WAVE
Start
Initialize the samples count Load P1 with the new level Decrement count No
SNGCE, KADAYIRUPPU
TF1 = 1? YES
NO
NO
A= 0xFF?
DEPARTMENT OF ECE
24
SNGCE, KADAYIRUPPU
Call DELAY: Load TL1, TH1 Clear TR1, TF1 Toggle P2.3
TF1 = 1? YES
NO
DEPARTMENT OF ECE
25
SNGCE, KADAYIRUPPU
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
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
EMBEDDED SYSTEMS LAB MOV TH0,#0FCH SETB TR0 BACK1: JNB TF1, BACK1 CLR TR0 CLR TF0 RET END
SQUARE WAVE
DEPARTMENT OF ECE
28
SNGCE, KADAYIRUPPU
RESULT: An assembly program to generate the given waveform of the required specification has been executed and the output has been observed in the Logic Analyzer.
DEPARTMENT OF ECE
29
SNGCE, KADAYIRUPPU
SORTING OF NUMBERS
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
ALGORITHM:
Start
No
DEPARTMENT OF ECE
31
SNGCE, KADAYIRUPPU
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
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
PALINDROME
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
ALGORITHM
Start Copy length of block
No
Move the content from source to destination Is Counter = 0? Increment both pointers Yes Decrement counter Reload the counter
No
Is Counter = 0?
SNGCE, KADAYIRUPPU
Decrement counter
Stop
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
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
Output Window:
DEPARTMENT OF ECE 37 SNGCE, KADAYIRUPPU
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
AIM: To find the cube 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. 9. Observe the result in the destination address through memory window.
DEPARTMENT OF ECE
39
SNGCE, KADAYIRUPPU
ALGORITHM
Start
Take it as count
Square =0
Square=square + odd no
Stop
DEPARTMENT OF ECE
40
SNGCE, KADAYIRUPPU
PROGRAM ORG 0000H SJMP 30H ORG 30H MOV R0,#50H MOV A,@R0 MOV B, A MOV R2, #01H MOV R1, A CLR A BACK: ADDC A, R2 INC R2 INC R2 DJNZ R1, BACK MUL AB INC R0 MOV @R0, A HERE: SJMP HERE END RESULT WINDOW: Input Window:
DEPARTMENT OF ECE
41
SNGCE, KADAYIRUPPU
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
AIM: To copy the message WELCOME from ROM to RAM. TOOLS REQUIRED: Vision from Keil for an 8051 microcontroller family. PROCEDURE: 1. 2. 3. 4. 5. 6. 7. 8. 9. Create a project in Vision. Set the device to AT89C51. The source code is written in the text window and is saved as .asm file. Add the source file into the Source Group. Build target. Start the debug session. Enter the data values in the source address through memory window. Run the program. Observe the result in the destination address through memory window.
43 SNGCE, KADAYIRUPPU
DEPARTMENT OF ECE
ALGORITHM:
Start
Initialise RAM pointer, data pointer and counter Define the string WELCOME in ROM
No
Yes
Stop
Decrement counter
DEPARTMENT OF ECE
44
SNGCE, KADAYIRUPPU
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
RESULT: An assembly program to copy the message WELCOME from ROM to RAM has been executed and the output has been verifed
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
EMBEDDED SYSTEMS LAB 8. Run the program. 9. Observe the result in the destination address through memory window.
ALGORITHM:
Start
Add LSBs and store it in next memory location DEPARTMENT OF ECE 47 Add MSBs location and store carry Increment With carry and store it in next location carry? Is Stop SNGCE, KADAYIRUPPU
Yes No
DEPARTMENT OF ECE
48
SNGCE, KADAYIRUPPU
PROGRAM:
ORG 0000H MOV R0,#50H MOV A,@R0 MOV R3,A INC R0 INC R0 MOV A,@R0 MOV R2,A ADD A,R3 MOV R5,A DEC R0 MOV A,@R0 MOV R3,A INC R0 INC R0 MOV A,@R0 ADDC A,R3 MOV R6,A MOV R1,#00H JNC NOCARRY INC R1 NOCARRY: INC R0
DEPARTMENT OF ECE 49 SNGCE, KADAYIRUPPU
EMBEDDED SYSTEMS LAB MOV A,R1 MOV @R0,A INC R0 MOV A,R6 MOV @R0,A INC R0 MOV A,R5 MOV @R0,A HERE:SJMP HERE END RESULT WINDOW Input Window:
Output Window:
RESULT: An assembly program to add two 16-bit numbers has been executed and the output has been verifed.
DEPARTMENT OF ECE
50
SNGCE, KADAYIRUPPU
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
ALGORITHM:
Start
Clear Sum and Carry Add Sum with the content of the memory location
have
If carry=0
Yes
No
Increment carry
Decrement limit
Decrement limit
No If limit=0
52
SNGCE, KADAYIRUPPU
DEPARTMENT OF ECE
53
SNGCE, KADAYIRUPPU
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
EMBEDDED SYSTEMS LAB RESULT: An assembly program to find sum of BCD numbers was successfully. executed
DEPARTMENT OF ECE
55
SNGCE, KADAYIRUPPU
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
ALGORITHM:
Start
Stop
DEPARTMENT OF ECE
57
SNGCE, KADAYIRUPPU
PROGRAM: ORG 0000H MOV R0, #50H MOV A,@R0 MOV R2, A ANL A, #0FH ADD A, #30H INC R0 MOV @R0, A MOV A, R2 ANL A, #0F0H SWAP A ADD A, #30H INC R0 MOV @R0, A HERE: SJMP HERE END RESULT WINDOW: Input Window:
Output Window:
DEPARTMENT OF ECE
58
SNGCE, KADAYIRUPPU
RESULT: An assembly program to for converting packed BCD to ASCII has been executed and the output has been verifed.
DEPARTMENT OF ECE
59
SNGCE, KADAYIRUPPU
AIM: To convert series packed BCD to ASCII. 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
60
SNGCE, KADAYIRUPPU
Increment location
Decrement count
YES
DEPARTMENT OF ECE
61
SNGCE, KADAYIRUPPU
PROGRAM: ORG 0000H MOV R0, #50H MOV R1, #60H MOV R4, #04H BACK1: MOV A,@R0 MOV R3, A ANL A, #0FH MOV R5, A INC R0 MOV A,@R0 ANL A, #0FH SWAP A ADD A, R5 INC R1 MOV @R1, A INC R0 DJNZ R4, BACK1 HERE: SJMP HERE END RESULT WINDOW: Input Window:
DEPARTMENT OF ECE
62
SNGCE, KADAYIRUPPU
Output Window:
RESULT: An assembly program to convert a series of packed BCD to ASCII has been executed and the output has been verifed.
DEPARTMENT OF ECE
63
SNGCE, KADAYIRUPPU
AIM: To convert a series of ASCII numbers to Packed BCD. 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
64
SNGCE, KADAYIRUPPU
PROGRAM
Start
Copy the number from memory location Store the result in the memory location
Multiply it by 0FH to get the LSB If count=0 Add the MSB and LSB to get the BCD number Stop
DEPARTMENT OF ECE
65
SNGCE, KADAYIRUPPU
PROGRAM: ORG 00H MOV R0, #50H MOV A,@R0 MOV R6,A MOV R1,#51H MOV R0,#60H LOOP: MOV A,@R1 ANL A, #0FH SWAP A MOV B, A INC R1 MOV A,@R1 ANL A, #0FH ORL A, B MOV @R0, A INC R0 INC R1 DJNZ R6, LOOP HERE:SJMP HERE END
DEPARTMENT OF ECE
66
SNGCE, KADAYIRUPPU
DEPARTMENT OF ECE
67
SNGCE, KADAYIRUPPU
Output Window:
RESULT: An assembly program to convert a series of ASCII numbers to packed BCD has been executed and the output has been verifed.
DEPARTMENT OF ECE
68
SNGCE, KADAYIRUPPU
CHECKSUM
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
PROGRAM:
Start
Input string
Store data
STOP
DEPARTMENT OF ECE
70
SNGCE, KADAYIRUPPU
PROGRAM: ORG 0000H MOV R3, #05H MOV R0, #20H MOV DPTR, #MYDATA LOOP: CLR A MOVC A,@A+DPTR MOV @R0, A INC R0 INC DPTR DJNZ R3, LOOP MOV R3, #05H MOV R0, #20H CLR A LOOP1: ADD A,@R0 INC R0 DJNZ R3, LOOP1 CPL A INC A INC R0 MOV @R0, A SJMP $ ORG 30H MYDATA: DB "HELLO" END RESULT WINDOW:
DEPARTMENT OF ECE
71
SNGCE, KADAYIRUPPU
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
TRANSPOSE OF A MATRIX
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
ALGORITHM
Start
Load: Source Location Destination Location Number of rows (R) Number of columns (C)
Is count<0?
Total
Transposed matrix=content of the current location and copy to destination location address Stop
No
74
SNGCE, KADAYIRUPPU
DEPARTMENT OF ECE
75
SNGCE, KADAYIRUPPU
EMBEDDED SYSTEMS LAB PROGRAM: ORG 0000H MOV R0,#20H MOV R1, #30H MOV R3, #3H MOV R4, #04H LOOP: MOV R6,#4H MOV A,@R0 MOV @R1, A LOOP1: INC R0 DJNZ R6, LOOP1 INC R1 DJNZ R3, LOOP MOV R3, #3H MOV A, R0 CLR C SUBB A, #4H CLR C SUBB A, #07H MOV R0, A DJNZ R4, LOOP HERE: SJMP HERE END RESULT WINDOW: Input Window:
DEPARTMENT OF ECE
76
SNGCE, KADAYIRUPPU
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
SIMPLE CALCULATOR
AIM: To implement a simple calculator 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
78
SNGCE, KADAYIRUPPU
ALGORITHM:
Start
Increment location
Yes Sub=A-B
1 Yes
Mul=A*B
No
1
No 1
Is choice=4
Div=A/B
Increment the location and store the result DEPARTMENT OF ECE 79 Stop 1 SNGCE, KADAYIRUPPU
EMBEDDED SYSTEMS LAB PROGRAM: ORG 0000H MOV R0, #40H MOV A,@R0 MOV R3, A INC R0 MOV A,@R0 MOV R4, A INC R0 MOV A,@R0 MOV R5, A CJNE R3, #01H,LOOP1 ADD A, R4 INC R0 MOV @R0, A JC LOOP SJMP HERE LOOP: INC R0 MOV A, #01H MOV @R0, A SJMP HERE LOOP1: CJNE R3, #02H, LOOP2 XCH A, R4 SUBB A, R4 INC R0 MOV @R0, A JC LOOP8 SJMP HERE LOOP8: INC R0 MOV A,#0FFH
DEPARTMENT OF ECE
80
SNGCE, KADAYIRUPPU
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, 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: A
DEPARTMENT OF ECE
81
SNGCE, KADAYIRUPPU
RESULT: An assembly program to impliment calculator has been executed and the output has been verifed.
Expt. No:19
DEPARTMENT OF ECE
FIBONACCI SERIES
82 SNGCE, KADAYIRUPPU
Date: 3/07/11
AIM: To generate Fibonacci series of 10 elements and store the results in internal memory. 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
83
SNGCE, KADAYIRUPPU
DEPARTMENT OF ECE
84
SNGCE, KADAYIRUPPU
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
Output Window:
RESULT: An assembly program to generate Fibonacci series of 10 elements has been written, executed and the output has been verifed.
DEPARTMENT OF ECE
86
SNGCE, KADAYIRUPPU