Sie sind auf Seite 1von 86

EMBEDDED SYSTEMS LAB

Expt. No: 1 Date: 12/07/11

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

EMBEDDED SYSTEMS LAB

ALGORITHM
Start Copy length of block

Initialize source block Pointer Initialize destination Block pointer

Move the content from source to destination and clear the source pointer

No Is Counter = 0? Yes

Increment both pointers

Decrement counter

Stop

DEPARTMENT OF ECE

SNGCE, KADAYIRUPPU

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

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 Date: 12/07/11

EXCHANGE OF FIVE BYTES OF DATA

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

Start Copy length of block

Initialize source block Pointer Initialize destination Block pointer DEPARTMENT OF ECE 5 SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

Exchange content of Source and destination Memory location Increment both pointers

No Is Counter = 0? Yes

Decrement counter

Stop

PROGRAM ORG 0000H MOV R0, #20H


DEPARTMENT OF ECE 6 SNGCE, KADAYIRUPPU

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

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.

Expt. No: 3 Date: 15/7/11

MULTIPLICATION OF TWO 8 BIT NUMBERS

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

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

ALGORITHM:

Start

Take the multiplier and multiplicand from the location

Take the multiplier as count

Mul=Mul+multiplicand using addc instruction

Is carry? No

Increment the register Yes

No

Is count =0 Yes Store the result

DEPARTMENT OF ECE

Stop

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

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

EMBEDDED SYSTEMS LAB

Expt. No: 4 Date: 15/07/11


AIM:

SQUARE ROOT OF AN 8 BIT NUMBER

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

Set count to 0 Copy number from memory location

Subtract the number with odd numberYES

location

Increment count on each subtraction

location
Yes Is result=0 No No Is result=negative Yes Store count value to memory location

Write FF to memory location

DEPARTMENT OF ECE

13

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

Expt. No: 5 Date: 15/07/11

SQUARE OF AN 8 BIT NUMBER

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

Copy number from memory location

Set count =number

add the number with next odd number

YES location

Decrement the count

No Increment by 2 Is count=0 Yes Store the result DEPARTMENT OF ECE 17 Stop SNGCE, KADAYIRUPPU

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

EMBEDDED SYSTEMS LAB END RESULT WINDOW: Input Window:

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

EMBEDDED SYSTEMS LAB

Expt. No: 6 Date: 19/07/11


AIM:

WAVE FORM GENERATION

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

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))

CORRESPONDING DECIMAL TO DAC VALUE=VOUT*25.6 128 192 238 255


SNGCE, KADAYIRUPPU

0 30 60 90

0 0.5 0.866 1.0


21

5 7.5 9.33 10

DEPARTMENT OF ECE

EMBEDDED SYSTEMS LAB

120 150 180 210 240 270 300 330 360


2. SQUARE WAVE Delay Calculation:

0.866 0.5 0 -0.5 -0.866 -1.0 -.866 -0.5 0

9.33 7.5 5 2.5 .669 0 .669 2.5 5

238 192 128 64 17 0 17 64 128

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

EMBEDDED SYSTEMS LAB

1. SINE WAVE
Start

Define the lookup table part of the code space

Initialize the samples count Load P1 with the new level Decrement count No

Get the next level from table

Count = 0? Yes DEPARTMENT OF ECE Stop 23

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB 2. SQUARE WAVE:


Start Add #33h and load P2 Configure TMOD register Call DELAY1: Load TL1, TH1

Clear ACC and load P2

Call DELAY2: Load TL0, TH0

Start Timer1: set TR1

Start Timer0: set TR0

TF1 = 1? YES

NO

TF0 = 1? YES Clear TR0, TF0

NO

Clear TR1, TF1 YES NO

A= 0xFF?

DEPARTMENT OF ECE

24

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB 3.STAIRCASE WAVE:


Start

Configure TMOD register

Clear ACC and load P2.3

Call DELAY: Load TL1, TH1 Clear TR1, TF1 Toggle P2.3

Start Timer0: set TR1

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

RESULT WINDOW: SINE WAVE

SQUARE WAVE

DEPARTMENT OF ECE

28

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB STAIRCASE WAVE

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

EMBEDDED SYSTEMS LAB

Expt. No:7 Date: 19/7/11

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

EMBEDDED SYSTEMS LAB

ALGORITHM:
Start

Copy length of block Initialize outer counter

Initialize inner counter

Initialize memory pointers

Compare two numbers

Increment memory pointers

Is carry flag set? Yes Exchange two numbers

No

Decrement inner counter No Is counter=0? Yes Decrement outer counter No Is counter=0?

DEPARTMENT OF ECE

31

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB


No Stop

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

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

EMBEDDED SYSTEMS LAB

Expt. No: 8 Date: 22/07/11


AIM:

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

EMBEDDED SYSTEMS LAB

ALGORITHM
Start Copy length of block

Initialize source block Pointer Initialize destination Block pointer

No

Move the content from source to destination Is Counter = 0? Increment both pointers Yes Decrement counter Reload the counter

Compare the first bytes from 2 locations

No

No Is equal? Yes DEPARTMENT OF ECE 35

Is Counter = 0?

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB


Yes Store 11 to memory

Decrement counter

Store FF to memory location

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

RESULT WINDOW: Input Window:

Output Window:
DEPARTMENT OF ECE 37 SNGCE, KADAYIRUPPU

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

EMBEDDED SYSTEMS LAB

Expt. No: 9 Date: 22/07/11

CUBE OF AN 8 BIT NUMBER

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

EMBEDDED SYSTEMS LAB

ALGORITHM
Start

Take no. from memory location

Take it as count

Get first odd no.

Square =0

Square=square + odd no

Increment by 2 to obtain next odd No Is count==no Yes Cube=Square*number

Stop

DEPARTMENT OF ECE

40

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

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

EMBEDDED SYSTEMS LAB

Expt. No: 10 Date: 26/07/11

COPY THE MESSAGE FROM 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. 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

EMBEDDED SYSTEMS LAB

ALGORITHM:

Start

Initialise RAM pointer, data pointer and counter Define the string WELCOME in ROM

Move the current byte from ROM to accumulator

No

Move the byte from accumulator to target location Is Counter = 0?

Yes

Increment RAM poniter and data pointer

Stop

Decrement counter

DEPARTMENT OF ECE

44

SNGCE, KADAYIRUPPU

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

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 Date: 26/07/11

ADDITION OF TWO 16-BIT NUMBERS

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

Load DPTR with memory location

Copy LSB first no and increment pointer

Copy MSB of first no.and increment pointer

Copy LSB of second no.and increment pointer

Copy MSB of second no.and increment pointer

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

EMBEDDED SYSTEMS LAB

Yes No

DEPARTMENT OF ECE

48

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

Expt. No: 12 Date: 26/07/11

SUM OF 5 BCD NUMBERS

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

EMBEDDED SYSTEMS LAB

ALGORITHM:
Start

Load the limit from memory location

Load numbers from memory location

Clear Sum and Carry Add Sum with the content of the memory location

Add 0110 to nibble that value >1001

have

If carry=0

Yes

No
Increment carry

Increment memory location

Decrement limit

Decrement limit

No If limit=0

Display output DEPARTMENT OF ECE Stop

52

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB


Yes

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

EMBEDDED SYSTEMS LAB

Expt. No: 13 Date: 30/07/11

CONVERSION PACKED BCD TO ASCII

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

EMBEDDED SYSTEMS LAB

ALGORITHM:
Start

Move the packed BCD data into the accumulator

Get the LSB and add with 30h

Store the converted ASCII

Get the MSB.

Swap MSB and add with 30h

Store the converted ASCII

Stop

DEPARTMENT OF ECE

57

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

Expt. No: 14 Date: 30/07/11

SERIES OF PACKED BCD TO ASCII

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

EMBEDDED SYSTEMS LAB ALGORITHM:


Start

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

YES

Is count=0? No Yes Stop

DEPARTMENT OF ECE

61

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

Expt. No: 15 Date: 30/07/11

SERIES OF ASCII TO PACKED BCD

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

EMBEDDED SYSTEMS LAB

PROGRAM
Start

Enter the count

Copy the number from memory location Store the result in the memory location

Multiply it by 0FH and swap it to get the MSB

Copy the next number from memory location

Increment the memory location and decrement the count

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

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB

DEPARTMENT OF ECE

67

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB RESULT WINDOW: Input Window:

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

EMBEDDED SYSTEMS LAB

Expt. No: 16 Date: 2/08/11

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

EMBEDDED SYSTEMS LAB

PROGRAM:
Start

Input string

Initialize source block pointer

Initialize destination block pointer

Exchange contents of source and destination

Add hex value of string

No Is counter=0 Yes Twos compliment

Store data

STOP

DEPARTMENT OF ECE

70

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

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

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

EMBEDDED SYSTEMS LAB

Expt. No: 17 Date: 2/08/11

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

EMBEDDED SYSTEMS LAB

ALGORITHM

Start

Load: Source Location Destination Location Number of rows (R) Number of columns (C)

Is count<0?

Increment source location by one Initialize: Column Count = number of columns

Total

Transposed matrix=content of the current location and copy to destination location address Stop

Increment the source location by R and increment destination by one

Is location>R*C+s DEPARTMENT OF ECE ource address?

No

74

SNGCE, KADAYIRUPPU

EMBEDDED SYSTEMS LAB

Decrement count (=R) by one

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

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

EMBEDDED SYSTEMS LAB

Expt. No:18 Date:3/08/11

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

EMBEDDED SYSTEMS LAB

ALGORITHM:

Start

Load the memory location

Load choice from that location

Increment location

Copy first operand

Increment location and copy second no.

Yes Is choice=1 Sum=A+B 1 No

Is choice=2 No Yes Is choice=3

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

EMBEDDED SYSTEMS LAB Output Window:

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

EMBEDDED SYSTEMS LAB

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

EMBEDDED SYSTEMS LAB ALGORITHM:


Start

Initialize location and load count from it and decrement by 2

Copy first no. to memory

Copy second no. to memory

Decrement pointer to get the previous number M(I-1), while A = M(I)

Next number I = M(I 1) + M(I)

Increment pointer and Decrement counter

Store the result

No Is count=0? Yes Stop

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

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.

DEPARTMENT OF ECE

86

SNGCE, KADAYIRUPPU

Das könnte Ihnen auch gefallen