Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Microcontroller Lab

Microcontroller Lab

Ratings: (0)|Views: 6,176|Likes:
Published by Pavan Kumar P N
8051 Micro controller programming with Keil
8051 Micro controller programming with Keil

More info:

Published by: Pavan Kumar P N on Apr 04, 2011
Copyright:Public Domain

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

10/06/2013

pdf

text

original

 
MICROCONTROLLER LAB
PART I: PROGRAMMINGLAB 1Working with KEIL uVision3:
Project, New uVision Project, M1, Save, Atmel, AT89C51ED2, OK, YesFile, New, (enter program code), Save, File-name=M1.ASM, SaveTarget1, Source Group1, Add Files to Group ‘Source Group1’, M1.ASM, Add, CloseProject, Options for Target ‘Target1’XTAL(MHz) = 11.0592Use On-chip ROM (0 FFFF)Use On-chip XRAM (0 – 06FF)OK Project, Options for Target ‘Target1’DebugUse Simulator Load Application at StartupOK Project, Build TargetDebug, Start/Stop Debug Session, OK Reset, Run, Stop RunningView, Memory Window, C:0000H, X:0000H, I:00HView Disassembly Window(Come out of Debug to edit)
ASSEMBLY LANGUAGE PROGRAMS; 8-BIT ones complement:
ORG 0000HMOV R0, #00HMOVX A,@R0CPL AINC R0MOVX @R0, ASJMP $END; input: X:0000H = 6AH; output: X:0001H = 95H
 
; BLOCK MOVE: WAP to transfer a block of 10 bytes of data from XRAM locations; 0000H-0009H to XRAM locations 0010H-0019H
.ORG 0000HMOV R0,#00H ; source pointer MOV R1,#10H ; destination pointeMOV R7,#0AH ; counter LOC1:MOVX A,@R0MOVX @R1, AINC R0INC R1DJNZ R7,LOC1SJMP $END; input: Put 10 bytes from X:0000H; output: Observe the 10 bytes from X:0010H;Assignment: Write BLOCK MOVE code without using R1.
; BLOCK EXCHANGE: WAP to exchange a block of 10 bytes of data from XRAM; locations 0000H-0009H with the data from XRAM locations 0010H-0019H.
 ORG 0000HMOV R0,#00H ; source pointeMOV R1,#10H ; destination pointer MOV R7,#0AH ; counter LOC1: MOVX A,@R0PUSH 0E0H ; push A onto stack MOVX A,@R1MOVX @R0,APOP 0E0HMOVX @R1,AINC R0INC R1DJNZ R7,LOC1SJMP $END; input: Put 10 bytes from X:0000H and 10 bytes from X:0010H; output: Observe the exchanged bytes.;Assignment: 1)Write BLOCK EXCHANGE code without using R1.; 2)Can you make the above program work using XCH A,@R1 ?
 
LAB 2; BUBBLE SORT(Ascending order): WAP to sort 10 unsigned numbers(bytes) stored in; INTERNAL RAM locations 40H-49H.
ORG 0000HMOV 32H,#09H ; count = length-1MOV 33H,32H ; additional counteLOC4:MOV R0,#40H ; pointeMOV R1,#41H ; make R1=R0+1MOV 34H,#00H ; Interchange flagLOC2:MOV A,@R0CLR CSUBB A,@R1 ; compare two successive numbersJZ LOC1JC LOC1MOV A,@R0XCH A,@R1MOV @R0,AMOV 34H,#0FFHLOC1: INC R0INC R1DJNZ 32H,LOC2MOV A,34H ; Is Interchange flag still 00H ?JZ LOC3DEC 33HMOV A,33HJZ LOC3MOV 32H,33HSJMP LOC4LOC3: SJMP $END ; input: Put 10 bytes from I:40H; output: Observe the 10 sorted bytes from I:40H;Assignment: 1)Write BUBBLE SORT code for DESCENDING order.; 2)Modify the above program using R2,R3,R4 instead of 32H,33H,34H.; 3)Modify the above program without INTERCHANGE FLAG.; 4)What is the use of JZ LOC1 in the above program?
; LARGEST ELEMENT IN AN ARRAY: WAP to find the largest element in an array of 10;unsigned numbers(bytes) stored in INTERNAL RAM locations 40H-49H and store the;result at location 30H
.ORG 0000HMOV R0,#40H ; pointer MOV R7,#0AH ; counteMOV 30H,@R0 ; get first number into 30HLOC3:MOV A,@R0CJNE A,30H,LOC1LOC1:JC LOC2 ; if 30H is greater, go to LOC2MOV 30H,ALOC2:INC R0

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->