mpi main file
Post on 30-May-2018
217 Views
Preview:
TRANSCRIPT
-
8/9/2019 MPI Main File
1/75
8086 MICROPROCESSOR
AIM: Study of Intel 8086 microprocessor trainer kit.
SYSTEM SPECIFICATION:
PROCESSORS:
CENTRAL PROCESSOR: 8086, 16 bit microprocessor operating in maximum
mode or 8088 8bit microprocessor.
CO-PROCESSOR: 8087 Numeric Data processor.
INPUT/OUTPUT: 8089 I/O processor.
MEMORY:
EPROM: 16K bytes of EPROM loaded with monitor expandable to 1024 bytes using
27256.
RAM: 16K bytes of CMOS RAM expandable to 256K bytes using 6264/62256
INPUT/OUTPUT:
PARELLEL: 24 I/O lines expandable to 72 lines (3 numbers of 8255A).
SERIAL: E/A RS-232 C (main)
TIMER/COUNTER: Three16 bit timer/counter through 8253.
OTHER INTERFACES: EPROM programmer for 2763/27128/27256.
KEYBOARD DISPLAY:28 keys and 8 seven segment display.
BUS: All address, data and control signals (ttl competitor) avoidable at edge
connector as per multi bus. The kit has own resident bus
PHYSICAL SIZE: 9.5 X 12.5
POWER SUPPLY:5V, 2.5A for kit, +12, -12, 250mA for CRT +24/21V for
EPROM programmer.
.OPERATING TEMPERATURE: 0 TO 50C.
CPU: 8086 is a 16 bit microprocessor and has 16 data lines and 20 address lines. The
lower 16 address lines are multiplexed with 16 data lines. Hence it becomes necessary
to latch the address lines. This is done by using 74LS373. we have used this kit in
maximum mode (MN/MX input held logically low) NMI input is connected to VCTINT key.
-
8/9/2019 MPI Main File
2/75
CO-PROCESSOR 8087: The co-processor monitor instructions fetched by the host
processor and recognizes certain of these as its own executes them.
INPUT/OUTPUT PROCESSOR 8089: The 8086 and 8088 are designed to be used
with 8089 in high performance input./output applications. 8089 resembles amicroprocessor with two DMA channels and an instruction set specifically tailored
for input/output operations. 8089 can serve i/o device directly. In addition, it can
transfer data from memory to memory and from i/o to i/o device.
CLOCK GENERATIONS:The clock generation circuit in the Intel 8284 clock
generator/driver. The circuit accepts crystal input, which operates at the frequency of
14.7456 MHz the driver divides the crystal frequency by three to produce 4.9MHz
clock signal required by the CPU.
BUS CONTROLLER: 8288 is a bus controller which decodes status output by an
8089. when the signal indicates that the processor is to run a bus cycle, 8288 issues arun command that identifies a bus cycle as memory read, memory write, i/o read, i/o
write e.t.c. it also provides a signal that strobes the address into latches.
BUS ARBITERS: 8289 is a bus arbiter that controls the access of a processor to a
multi master system resource (typically memory) that is shared by two or more
microprocessor (master).
MEMORY: 16KB of EPROM and 16KB of CMOS RAM has been provided with
20-biit address of 8086, a total of 1MB of memory can be addressed with the address
slots as 00000 to FFFFF.
I/O DEVICES:
8279: 8279 is a general purpose programmable keyboard and display device designed
for use with 8086 microprocessor.
8255: 8255 is a programmable peripheral interface (PPI) designed use with 8086
microprocessor. This basically acts as a general purpose i/o component to interface
peripherals equipments to the system bus.
8253: This chip is a programmable interval timer/counter and can be used for the
generation of accurate time delay. It has got three independent 16 bit counters eachhaving a count rate of up to 2MHz.
8251: This chip is a programmable communication interface and is used as a
peripheral device. This device accepts data character from the CPU in parallel from
and then converts them into a continuous serial data stream from transmission
simultaneously it can receive data stream and convert them into parallel data for the
stream and convert them into parallel data for the CPU. It can also signal CPU
whenever it can accept a new character for the transmission or whenever it has
received a character for the CPU.
DISPLAY: Eight digits of seven segment display has been provided on the trainerkit.
-
8/9/2019 MPI Main File
3/75
Algorithm:-
Start
SI 0200
AL [SI]
SI [SI] +1
BL [SI]
AL AL+BL
SI [SI] +1
[SI] AL
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data20202 Result
Result table:-
Memory Location Data
0200 56 H
0201 42 H
0202 98 H
Result: - AL= 56 H, BL= 42 H.
AL + BL= 98 H;
AL 98 H.
Addition of two 8 bit numbers
-
8/9/2019 MPI Main File
4/75
Aim: - To write an assembly language program to add two 8 bit numbers.
Program:-
MOV SI, 0200
MOV AL, [SI]
INC SI
MOV BL, [SI]
ADD AL, BL
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments0100
0103
0105
0106
0108
010A
010B
010D
BE0002
8A04
46
8A1C
00D8
46
8804
F4
MOV SI,0200
MOV AL,[SI]
INC SI
MOV BL,[SI]
ADD AL,BL
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Add AL and BL.
Increment SI.
Move AL to contents of SI.
End of the program.
Algorithm:-
Start
-
8/9/2019 MPI Main File
5/75
SI 0200
AL [SI]
SI [SI] +1
BL [SI]
AL AL - BL
SI [SI] +1
[SI] AL
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202 Result
Result table:-
Memory Location Data
0200 56 H0201 42 H
0202 14 H
Result: - AL= 56 H, BL= 42 H.
AL - BL= 14 H;AL 14 H.
Subtraction of two 8 bit numbers
Aim: - To write an assembly language program to subtract two 8 bit numbers.
-
8/9/2019 MPI Main File
6/75
Program:-
MOV SI, 0200MOV AL, [SI]
INC SI
MOV BL, [SI]
SUB AL, BL
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0108
010A
010B
010D
BE0002
8A04
46
8A1C
28D8
46
8804
F4
MOV SI,0200
MOV AL,[SI]
INC SI
MOV BL,[SI]
SUB AL,BL
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Subtract BL from Al.
Increment SI.
Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SI 0200
AL [SI]
SI [SI] +1
BL [SI]
AL AL*BL
-
8/9/2019 MPI Main File
7/75
SI [SI] +1
[SI] AL
SI [SI] +1
[SI] AH
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
Result0203
Result table:-
Memory Location Data
0200 10 H
0201 20 H
0202 00 H
0203 02 H
Result: - AL= 10 H, BL= 20 H.
AL * BL= 0200 H;
AL00
AH02
Multiplication of two 8 bit numbers
Aim: - To write an assembly language program to multiply two 8 bit numbers.
Program:-
MOV SI, 0200
MOV AL, [SI]
INC SIMOV BL, [SI]
-
8/9/2019 MPI Main File
8/75
MUL BL
INC SI
MOV [SI], AL
INC SI
MOV [SI], AH
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0108
010A
010B
010D
010E
0110
BE0002
8A04
46
8A1C
F6E3
46
8804
46
8824
F4
MOV SI,0200
MOV AL,[SI]
INC SI
MOV BL,[SI]
MUL BL
INC SI
MOV [SI],AL
INC SI
MOV [SI], AH
HLT
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Multiply AL and BL
Increment SI.
Move AL to contents of SI.
Increment SI
Move AH to contents of SI
End of the program.
Algorithm:-
Start
SI 0200
AL [SI]
SI [SI] +1
BL [SI]
AL AL BL
SI [SI] +1
[SI] AL
SI [SI] +1[SI] AH
-
8/9/2019 MPI Main File
9/75
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
Result0203
Result table:-
Memory Location Data
0200 20 H
0201 11 H
0202 01 H
0203 0F H
Result: - AL= 20 H, BL= 11 H.
Quotient: AL = 01 H,
Remainder: AH= 0F H.
Division of two 8 bit numbers
Aim: -To write an assembly language program to divide two 8 bit numbers.
Program:-
MOV SI, 0200MOV AL, [SI]
INC SI
MOV BL, [SI]
DIV BL
INC SI
MOV [SI], AL
INC SI
MOV [SI], AH
-
8/9/2019 MPI Main File
10/75
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0108
010A
010B
010D
010E
0110
BE0002
8A04
46
8A1C
F6F3
46
8804
46
8824
F4
MOV SI,0200
MOV AL,[SI]
INC SI
MOV BL,[SI]
DIV BL
INC SI
MOV [SI],AL
INC SI
MOV [SI], AH
HLT
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Divide AL by BL.
Increment SI.
Move AL to contents of SI.
Increment SI
Move AH to contents of SI
End of the program.
Algorithm:-
Start
SI 0400
AX [SI]
SI [SI] +1
SI [SI] +1
BX [SI]
AX AX+BX
SI [SI] +1
SI [SI] +1
[SI] AX
Stop
Reference table:-
Memory Location Data
0400 Data1
0401
0402 Data2
0403
-
8/9/2019 MPI Main File
11/75
0404 Result
0405
Result table:-
Memory Location Data
0400 F4 H
0401 56 H
0402 98 H
0403 92 H
0404 8C H
0405 E9 H
Result:-AX= 56F4 H, BX= 9298 H
AX + BX= E98C H;
Addition of two 16 bit numbers
Aim: -To write an assembly language program to add two 16 bit numbers.
Program:-
MOV SI, 0400
MOV AX, [SI]INC SI
INC SI
MOV BX, [SI]
ADD AX, BX
INC SI
INC SI
MOV [SI], AX
HLT
Assembly Language Program:-
-
8/9/2019 MPI Main File
12/75
Program address Opcode Mnemonics Comments
0100
0103
01050106
0107
0109
010B
010C
010D
010F
BE0004
8B04
4646
8B1C
01D8
46
46
8904
F4
MOV SI,0400
MOV AX, [SI]
INC SIINC SI
MOV BX, [SI]
ADD AX, BX
INC SI
INC SI
MOV [SI], AX
HLT
Initialize SI.
Move contents of SI to AX.
Increment SI.Increment SI.
Move contents of SI to BX.
Add AX and BX.
Increment SI.
Increment SI.
Move AX to contents of SI.
End of the program.
Algorithm:-
Start
SI 0400
AX [SI]
SI [SI] +1
SI [SI] +1
BX [SI]AX AX-BX
SI [SI] +1
SI [SI] +1
[SI] AX
Stop
Reference table:-
Memory Location Data
-
8/9/2019 MPI Main File
13/75
0400 Data1
0401
0402 Data2
0403
0404 Result0405
Result table:-
Memory Location Data
0400 A2 H
0401 D3 H
0402 41 H
0403 BC H0404 61 H
0405 17 H
Result: -AX= D3A2 H, BX= BC41 H.
AX-BX= 1761 H;
Subtraction of two 16 bit numbers
Aim: -To write an assembly language program to subtract two 16 bit numbers.
Program:-
MOV SI, 0400
MOV AX, [SI]
INC SI
INC SI
MOV BX, [SI]
SUB AX, BX
INC SI
INC SIMOV [SI], AX
-
8/9/2019 MPI Main File
14/75
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0107
0109
010B
010C010D
010F
BE0004
8B04
46
46
8B1C
29D8
46
468904
F4
MOV SI,0400
MOV AX, [SI]
INC SI
INC SI
MOV BX, [SI]
SUB AX, BX
INC SI
INC SIMOV [SI], AX
HLT
Initialize SI.
Move contents of SI to AX.
Increment SI.
Increment SI.
Move contents of SI to BX.
Subtract BX from AX.
Increment SI.
Increment SI.Move AX to contents of SI.
End of the program.
Algorithm:-
Start
SI 0400
AX [SI]
SI SI+1
SI SI+1
BX [SI]
AX AX*BX
SI SI+1SI SI+1
[SI] AX
SI SI+1
SI SI+1
[SI] AXStop
Reference table:-
Memory Location Data
-
8/9/2019 MPI Main File
15/75
0400 Data1
0401
0402 Data2
0403
0404 Result
0405
0406
0407
Result table:-
Memory Location Data
0400 A2 H
0401 02 H
0402 D3 H
0403 30 H
0404 86 H
0405 8B H
0406 80 H
0407 00 H
Result: - AX = 02A2 H, BX = 30D3 H.AX*BX= 808B86 H
AL 86; AH 8B; DL 80.
Multiplication of two 16 bit numbers
Aim: -To write an assembly language program to multiply two 16 bit numbers.
Program:-
MOV SI, 0400
MOV AX, [SI]
INC SI
INC SI
MOV BX, [SI]
MUL BX
INC SI
INC SI
MOV [SI], AX
INC SIINC SI
-
8/9/2019 MPI Main File
16/75
MOV [SI], DX
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0107
0109
010B
010C
010D010F
0110
0111
0113
BE0004
8B04
46
46
8B1C
F7E3
46
46
890446
46
8914
F4
MOV SI,0400
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
MUL BX
INC SI
INC SI
MOV [SI],AXINC SI
INC SI
MOV [SI],DX
HLT
Initialize SI.
Move contents of SI to AX.
Increment SI.
Increment SI.
Move contents of SI to BX.
Multiply AX and BX.
Increment SI.
Increment SI.
Move AX to contents of SI.Increment SI.
Increment SI.
Move DX to contents of SI.
End of the program.
Algorithm:-
Start
SI 0400
AX [SI]
SI SI+1
SI SI+1
BX [SI]
AX AXBX
SI SI+1
SI SI+1
[SI] AXStop
Reference table:-
Memory Location Data0400 Data1
-
8/9/2019 MPI Main File
17/75
0401
0402 Data2
0403
0404 Result
0405
Result table:-
Memory Location Data
0400 94 H
0401 78 H
0402 34 H
0403 12 H
0404 06 H
0405 00 H
0406 5C
0407 0B
Result: - AX = 7894 H, BX = 1234 H.
Quotient: AX = 0006 H,
Remainder: DX = 0B5C H.
Division of two 16 bit numbers
Aim: -To write an assembly language program to Divide two 16 bit numbers.
Program:-
MOV SI, 0400MOV AX, [SI]
INC SI
INC SI
MOV BX, [SI]
DIV BX
INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI],DX
-
8/9/2019 MPI Main File
18/75
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0107
0109
010B
010C
010D
010F0110
0111
0113
BE0004
8B04
46
46
8B1C
F7F3
46
46
8904
4646
8914
F4
MOV SI,0400
MOV AX, [SI]
INC SI
INC SI
MOV BX, [SI]
DIV BX
INC SI
INC SI
MOV [SI], AX
INC SIINC SI
MOV [SI],DX
HLT
Initialize SI.
Move contents of SI to AX.
Increment SI.
Increment SI.
Move contents of SI to BX.
Divide AX by BX.
Increment SI.
Increment SI.
Move AX to contents of SI.
Increment SI.Increment SI.
Move DX to contents of SI.
End of the program.
Algorithm:-
Start
SI 0200
AL [SI]
SI [SI] +1
BL [SI]
AL AL+BL
DECIMAL ADJUST AFTER ADDITION[IF THE RESULT
IS GREATER THAN 09 OR 90,ADD 06 OR 60 TO THE
LOWER NIBBLE OR HIGHER NIBBLE OF AL]
SI [SI] +1
[SI] AL
-
8/9/2019 MPI Main File
19/75
Stop
Reference table:-
Memory Location Data0500 Data1
0501 Data2
0502 Result
Result table:-
Memory Location Data
0500 87
050163
0502 50
Result: - AL= 87, BL= 63.
After BCD addition AL = 50;and
Carry flag is set.
Addition of two 8 bit BCD numbers
Aim: -To write an assembly language program to add two 8 bit BCD numbers.
Program:-
MOV SI, 0500
MOV AL, [SI]
INC SI
MOV BL, [SI]
ADD AL, BL
DAA
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
-
8/9/2019 MPI Main File
20/75
Program address Opcode Mnemonics Comments
0100
0103
0105
0106
0108
010A
010B
010C
010E
BE0005
8A04
46
8A1C
00D8
27
46
8804
F4
MOV SI,0500
MOV AL,[SI]
INC SI
MOV BL,[SI]
ADD AL,BL
DAA
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Add AL and BL.
Decimal adjust after addition.
Increment SI.
Move AL to contents of SI.
End of the program.
ALGORITHM:START
SI 0200
AL [SI]
SI SI+1
BL [SI]
AL AL+BL
ASCII ADJUST AFTER ADDITION
SI SI+1
[SI] ALSTOP
REFERENCE TABLE:
MEMORY LOCATION DATA
0500 DATA1(AL)
0501 DATA2(BL)
0502 RESULT(AL)
0503 RESULT(BL)
-
8/9/2019 MPI Main File
21/75
RESULT TABLE:
MEMORY LOCATION DATA
0500 36
0501 340502 00
0503 01
8-BIT ASCII ADDITION
AIM: To write an assembly language program for 8-bit ASCII addition.
Program:MOV SI,0500
MOV AL,[SI]
INC SI
MOV BL,[SI]
ADD AL,BLAAA
INC SI
MOV [SI],AL
INC SI
MOV [SI],AH
HLT
ASSEMBLY LANGUAGE PROGRAM TABLE:
-
8/9/2019 MPI Main File
22/75
PROGRAM
ADDRESS
OPCODE MNEUMONICS COMMENTS
0100 BE0002 MOV SI, 0500 Initialize the memory location
0200 to SI
0103 8A04 MOV AL, [SI] Move the contents of SI to AL
0105 46 INC SI Increment SI0106 8A1C MOV BL, [SI] Move the contents of SI to BL
0108 00D8 ADD AL, BL Addition of AL and BL
010A 37 AAA ASCII Addition Accumulator
010B 46 INC SI Increment SI
010C 8804 MOV [SI], AL Move AL to contents of SI
010E 46 INC SI Increment SI
010F 8824 MOV [SI],AH Move the contents of AH into
SI
0111 F4 HLT End of the program
ALGORITHM:
START
SI 0200
AL [SI]
CL 04
AL AL+ [SI+01]
SI SI+1
CL CL-1
JNZ Jumps to program address 0107 until CL is not zero[SI] AL
STOP
REFERENCE AND INPUT TABLE:
MEMORY LOCATION REFERENCE DATA INPUT TABLE
0200 DATA1 01H
0201 DATA2 04H
0202 DATA3 06H0203 DATA4 03H
-
8/9/2019 MPI Main File
23/75
0204 DATA5 01H
RESULT TABLE:
MEMORY LOCATION DATA
0200 0FH
MULTIBYTE ADDITION
AIM: To write an assembly language program to perform multibyte addition
PROGRAM:
MOV SI, 0200
MOV AL, [SI]
MOV CL, 04
L1: ADD AL, [SI+01]
INC SI
DEC CL
JNZ L1 (0107)
MOV [SI], AL
HLT
ASSEMBLY LANGUAGE PROGRAM TABLE:
-
8/9/2019 MPI Main File
24/75
PROGRAM
ADDRESS
OPCODE MNEUMONICS COMMENTS
0100 BE0002 MOV SI, 0200 Initialize the memory location
0200 to SI
0103 8A04 MOV AL, [SI] Move the contents of SI to AL
0105 B104 MOV CL, 04 Move the data 04 to CL0107 024401 ADD AL, [SI+01] Move the contents of [SI+01] to
AL
010A 46 INC SI Increment SI
010B FEC9 DEC CL Decrement CL
010C 75F8 JNZ 0107 Jumps to location 0107 until CL
is zero
010D 8804 MOV [SI], AL Move AL to the contents of SI
0111 F4 HLT End of the program
Algorithm:-
Start
SI 0200
AL [SI]
AL AL
SI [SI] +1
[SI] AL
Stop
Reference table:-
Memory Location Data0600 Data1
-
8/9/2019 MPI Main File
25/75
0601 Data2
Result table:-
Memory Location Data
0600 AD
0601 52
Result: - AL= AD
After complementing AL= 52;
1s complement of a 8 bit number
Aim: -To write an assembly language program to Find 1s compliment of a given
number.
Program:-
MOV SI, 0600
MOV AL, [SI]
NOT AL
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
-
8/9/2019 MPI Main File
26/75
0100
0103
0105
01070108
010A
BE0006
8A04
F6D0
468804
F4
MOV SI,0600
MOV AL,[SI]
NOT AL
INC SIMOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Complement AL.
Increment SI.Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SI 0600
AL [SI]
AL AL+1
SI [SI] +1
[SI] AL
Stop
Reference table:-
Memory Location Data
0600 Data1
0601 Data2
Result table:-
-
8/9/2019 MPI Main File
27/75
Memory Location Data
0600 FD H
0601 03 H
Result: - AL= AD
After complementing AL= 52;
2s complement of a 8 bit number
Aim: -To write an assembly language program to Find 2s compliment of a given
number.
Program:-
MOV SI, 0600
MOV AL, [SI]
NEG AL
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
-
8/9/2019 MPI Main File
28/75
0100
0103
0105
01070108
010A
BE0006
8A04
F6D0
468804
F4
MOV SI,0600
MOV AL,[SI]
NEG AL
INC SIMOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Complement AL and ADD 1
Increment SI.Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SI 0600
AL [SI]
BL AL
BL BL+1
L1: AL AL*BL
BL BL+1
If ZF = 1 continue, else jump to L1.
SI SI+1
[SI] AL
Stop
Reference table:-
Memory Location Data
0600 Data10601 Data2
-
8/9/2019 MPI Main File
29/75
Result table:-
Memory Location Data
0600 05 H0601 78 H
Result: - AL= 05 H.
Factorial of AL= 78 H;
Factorial of a given Number
Aim: -To write an assembly language program to Find Factorial of a given
Number.
Program:-
MOV SI, 0600
MOV AL, [SI]
MOV BL, AL
DEC BL
L1: MUL BL
DEC BL
JNZ L1
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
-
8/9/2019 MPI Main File
30/75
0100
0103
0105
01070109
010B
010D
010F
0110
0112
BE0006
8A04
88C3
FECBF6E3
FECB
75FA
46
8804
F4
MOV SI,0600
MOV AL,[SI]
MOV BL,AL
DEC BLMUL BL
DEC BL
JNZ 0109
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Move AL to BL.
Decrement BL.Multiply BL With AL.
Decrement BL.
Jump Non Zero (If ZF = 1
continue, else jump to 0109).
Increment SI.
Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SUBROUTINE PROGRAM : ( L1: CL AL
CL CL-1
L2: AL AL*Cl
CL CL-1
If ZF =1 Continue, Else Jump to L2.
Return to Called Location.)
MAIN PROGRAM : SI 0400
AL [SI]
SI SI+1
BL [SI]
DL AL
AL AL-BL
Call SUBROUTINE PROGRAM
AL DL
DL ALCall SUBROUTINE PROGRAM
AL BL
-
8/9/2019 MPI Main File
31/75
BL AL
Call SUBROUTINE PROGRAM
AL AL*DL
AL BLAL AL/BL
SI SI+1
[SI] AL
Stop
COMPUTE nCr
Aim: -To write an assembly language program to find Number of Combinations by
Using the formula of
n
Cr.
Program:-
MOV CL, AL
DEC CL
MUL CL
DEC CLJNZ 0104
RET
MOV SI, 0400
MOV AL, [SI]
INC SI
MOV BL,[SI]
MOV DL, ALSUB AL, BL
-
8/9/2019 MPI Main File
32/75
CALL 0100
XCHG AL, DL
CALL 0100
XCHG AL, BL
CALL 0100
MUL DL
XCHG AL, BL
DIV BL
INC SI
MOV [SI], AL
HLT
Reference table:-
Memory Location Data
0400 Data1
0401 Data2
0402 Result
Result table:-
Memory Location Data
0400 05 H
0401 03 H
0402 0A H
Result: - AL= 05 H, BL= 03 H.
5C3 = 0A H.
-
8/9/2019 MPI Main File
33/75
-
8/9/2019 MPI Main File
34/75
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0102
0104
0106
0108
010A
010B
010E
0110
0111
0113
0115
0117
011A
011C
011F
0121
0124
0126
0128
012A
012B
012D
88C1
FEC9
F6E1
FEC9
75FA
C3
BE0004
8A04
46
8A1C
88C2
28D8
E8E6FF
86C2
E8E1FF
86C3
E8DCFF
F6E2
86C3
F6F3
46
8804
F4
MOV CL,AL
DEC CL
MUL CL
DEC CL
JNZ 0104
RET
MOV SI,0400
MOV AL,[SI]
INC SI
MOV BL,[SI]
MOV DL,AL
SUB AL,BL
CALL 0100
XCHG AL,DL
CALL 0100
XCHG AL,BL
CALL 0100
MUL DL
XCHG AL,BL
DIV BL
INC SI
MOV [SI],AL
HLT
Move AL to CL.
Decrement CL.
Multiply AL and CL.
Decrement CL.
(Jump Non Zero) If ZF =1
Continue, Else Jump to 0104.
Return to Called Location.
Initialize SI.
Move contents of SI to AL.
Increment SI.
Move contents of SI to BL.
Move AL to DL.
Subtract BL from AL.
Call Label 0100.
Exchange AL and DL.
Call label 0100
Exchange AL and BL.
Call Label 0100
Multiply AL and DL.Exchange AL and BL.
Divide AL by BL.
Increment SI.
Move AL to contents of SI.
End of the program.
-
8/9/2019 MPI Main File
35/75
Algorithm:-
Start
DX 0003
L1: DI 0200
CX 0005L2: AL [DI]
Compare AL with [DI+01]
If AL < [DI+01] Then jump to L3, else continue.
AL [DI+01][DI] AL
L3: DI DI+1
Loop: Jump to L2 if CX 0, else continue.
DX DX+1
CX DX
Loop: Jump to L1 if CX 0, else continue.Stop
Ascending Order
-
8/9/2019 MPI Main File
36/75
Aim: -To write an assembly language program Sort given numbers in ascending
order.
Program:-
MOV DX, 0003
L1: MOV DI, 0200
MOV CX, 0003
L2: MOV AL, [DI]
CMP AL, [DI+01]
JL L3
XCHG AL, [DI+01]
MOV [DI], AL
L3: INC DI
LOOP L2
DEC DX
MOV CX, DX
LOOP L1
HLT
-
8/9/2019 MPI Main File
37/75
Reference table:-
Memory Location Input Data
0200 86H
0201 34H
0202 08H
0203 91H
0204 57H
Result table:-
Memory Location Output Data
0200 08H
0201 34H
0202 57H
0203 86H
0204 91H
Assembly Language Program:-
Program address Opcode Mnemonics Comments
-
8/9/2019 MPI Main File
38/75
0100
0103
0106
0109010B
010E
0110
0113
0115
0116
0118
0119
011B
011D
BA0300
BF0002
B90300
8A053A4501
7C05
864501
8805
47
E2F1
4A
89D1
E2E6
F4
MOV DX,0003
MOV DI,0200
MOV CX,0003
MOV AL,[DI]CMP AL,[DI+01]
JL 0115
XCHG AL, [DI+01]
MOV [DI],AL
INC DI
LOOP 0109
DEC DX
MOV CX,DX
LOOP 0103
HLT
Move 03 to DX.
Initialize DI.
Move 03 to CX.
Move contents of DI to AL.Compare AL & [DI + 01]
If AL < [DI+01] Then jump
to 0115, else continue.
Exchange AL, [DI + 01]
Move AL to contents of DI.
Increment DI.
Loop: Jump to 0109 if CX
0, else continue.
Decrement DX.
Move DX to CX.
Loop: Jump to 0103 if CX
0, else continue.
End of the program.
Algorithm:-
Start
DX 0003
-
8/9/2019 MPI Main File
39/75
L1: DI 0200
CX 0003
L2: AL [DI]
Compare AL, [DI+01]
If AL > [DI+01] Then jump to L3, else continue.
AL [DI+01][DI] AL
L3: DI DI+1
Loop: Jump to L2 if CX 0, else continue.
DX DX+1
CX DX
Loop: Jump to L1 if CX 0, else continue.
Stop
Descending Order
-
8/9/2019 MPI Main File
40/75
Aim: -To write an assembly language program Sort given numbers in Descending
order.
Program:-
MOV DX, 0003
L1: MOV DI, 0200
MOV CX, 0003
L2: MOV AL, [DI]
CMP AL, [DI+01]
JG L3XCHG AL, [DI+01]
MOV [DI], AL
L3: INC DI
LOOP L2
DEC DX
MOV CX, DX
LOOP L1
HLT
-
8/9/2019 MPI Main File
41/75
Reference table:-
Memory Location Input Data
0200 86H
0201 34H
0202 29H
0203 91H
0204 57H
Result table:-
Memory Location Output Data
0200 91H
0201 86H0202 57H
0203 34H
0204 29H
Assembly Language Program:-
Program address Opcode Mnemonics Comments
-
8/9/2019 MPI Main File
42/75
0100
0103
0106
0109010B
010E
0110
0113
0115
0116
0118
0119
011B
011D
BA0300
BF0002
B90300
8A053A4501
7F05
864501
8805
47
E2F1
4A
89D1
E2E6
F4
MOV DX,0003
MOV DI,0200
MOV CX,0003
MOV AL,[DI]CMP AL,[DI+01]
JG 0115
XCHG AL, [DI+01]
MOV [DI],AL
INC DI
LOOP 0109
DEC DX
MOV CX,DX
LOOP 0103
HLT
Move 03 to DX.
Initialize DI.
Move 03 to CX.
Move contents of DI to AL.Compare AL & [DI + 01]
If AL > [DI+01] Then jump to
0115, else continue.
Exchange AL, [DI + 01]
Move AL to contents of DI.
Increment DI.
Loop: Jump to 0109 if CX
0, else continue.
Decrement DX.
Move DX to CX.
Loop: Jump to 0103 if CX
0, else continue.
End of the program.
Algorithm:-
StartSI 0200
-
8/9/2019 MPI Main File
43/75
AL [SI]
CL 08
L1: Rotate the bits of AL to right once.
If CF is set continue, else jump to L2.
BL BL+1
L2: If CX=0 continue, else jump to L1.
Stop
Reference table:-
Memory Location Data
0200 Data1
Result table:-
Memory Location Data
0200 56 H
Result: - AL= 56 H.
Numbers of ones in AL are in BL: 04
Count numbers of ones in a number
Aim: -To write an assembly language program to Count Number of ones in a
number.
-
8/9/2019 MPI Main File
44/75
Program:-
MOV SI,0200MOV AL,[SI]
MOV CL, 08
L1: RCR AL, 1
JNC L2
INC BL
L2: LOOP L1
HLT
Assembly Language Program:-
Program
address
Opcode Mnemonics Comments
0100
0103
0105
0107
0109
010B
010D
010F
BE0002
8A04
B108
D0D8
7302
FEC3
E2F8
F4
MOV SI,0200
MOV AL,[SI]
MOV CL,08
RCR AL,1
JNB 010D
INC BL
LOOP 0107
HLT
Initialize SI
Move contents of SI to AL.
Move 08 to CL.
Rotate Right AL by one bit.
Jump Non Carry to the Label. (If CF
is set continue, else jump to L2.)
Increment BL.
If CX=0 continue, else jump to
0107.
End of the Program.
Algorithm:-
Start
SI 0200
CX 0008
DI 0220Clear direction flag
-
8/9/2019 MPI Main File
45/75
Prefix of MOVSB repeat MOVSB until CL=0 or ZF0.
Move byte or word from one string to another.
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202 Data3
0203 Data4
0204 Data 5
0220-0224 RESULT
Result table:-
Memory Location Data
0200 01 H
0201 02 H
0202 03 H
0203 04 H
0204 05 H
0220 01 H0221 02 H
0222 03 H
0223 04 H
0224 05 H
Result: - Block of Data in been transferred.DF=0;CF=1;ZF=1.
Moving Block Of Data
Aim: -To write an assembly language program to Move block of data using stringinstructions.
-
8/9/2019 MPI Main File
46/75
Program:-
MOV SI,0200
MOV CX,0008
MOV DI ,0220
CLD
REPZ
MOVSB
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0106
0109
010A
010B
010C
BE0002
B90800
BF2002
FC
F3
A4
F4
MOV SI,0200
MOV CX,0008
MOV DI,0220
CLD
REPZ
MOVSB
HLT
Initialize SI.
Move 08 to CL.
Initialize DI.
Clear direction flag.
Prefix of MOVSB repeat MOVSB until
CL=0 or ZF0.
Move byte or word from one string to
another.
End of program
Algorithm:-
Start
SI 0200
CX 000A
AL [SI]
L1: AL [0200]BL BL+1
-
8/9/2019 MPI Main File
47/75
AL AL*BL
SI SI+1
[SI] AL
If CL=0 continue, else jump to L1.
Stop
Reference table:-
Memory Location Data
0200
0201
0202
0203
0204
0205 Generated Table0206
0207
0208
0209
020A
Result table:-
Memory Location Data
0200 03 H0201 03 H
0202 06 H
0203 09 H
0204 0C H
0205 0F H
0206 12 H
0207 15 H
0208 18 H
0209 1B H020A 1E H
Result: - Table has been generated for 03 H. ZF is effected.
Table generation.
Aim: -To write an assembly language program to generate Table for a givennumber.
Program:-
-
8/9/2019 MPI Main File
48/75
MOV SI,0200
MOV CX,000A
MOV AL,[SI]
MOV AL, [0200]
INC BL
MUL BL
INC SI
MOV [SI],AL
LOOP 0108
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0106
0108
010B
010D
010F
0110
0112
0114
BE0002
B90A00
8A04
A00002
FEC3
F6E3
46
8804
E2F4
F4
MOV SI,0200
MOV CX,000A
MOV AL,[SI]
MOV AL,[0200]
INC BL
MUL BL
INC SI
MOV [SI],AL
LOOP 0108
HLT
Initialize SI.
Move 0A to CX.
Move contents of Si to AL.
Move [0200] to AL.
Increment BL.
Multiply BL with AL.
Increment SI.
Move AL to contents of Si
Jump to 0108 until CX=0.
End of program
Algorithm:-
Start
SI 0200
AL [SI]
BL AL
-
8/9/2019 MPI Main File
49/75
Shift bits of BL to Right.
AL AL* BL
SI SI+1
[SI] AL
Stop
Reference table:-
Memory Location Data0200 Data1
0201 Result
Result table:-
Memory Location Data
0200 12 H
0201 1B H
Result: - Converting 12 H to Gray gives 1B H.CF=1.
Binary to Gray
Aim: -To write an assembly language program to convert Binary number to Gray.
Program:-
-
8/9/2019 MPI Main File
50/75
MOV SI, 0200
MOV AL, [SI]
MOV BL, AL
SHR BL, 1
XOR AL,BL
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0105
0107
0109
010B
010C
010E
BE0002
8A04
88C3
D0EB
30D8
46
8804
F4
MOV SI,0200
MOV AL,[SI]
MOV BL,AL
SHR BL,1
XOR AL,BL
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move contents of SI to AL.
Move AL to BL.
Shift Right BL by 1 bit.
AL EX OR BL
Increment SI.
Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SI 0200
AL [SI]
-
8/9/2019 MPI Main File
51/75
BL AL
L1: Shift bits of BL to Right.
AL BL
CL CL+1
If CL=0 continue, else jump to L1.
SI SI+1
[SI] AL
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Result
Result table:-
Memory Location Data
0200 85 H
0201 F9 H
Result: - Converting Gray 85 H to Binary gives F9 H.CF=1.
Gray to Binary
Aim: -To write an assembly language program to convert Gray number to Binary.
Program:-
MOV SI,0200
MOV CL,08
MOV AL,[SI]MOV BL,AL
-
8/9/2019 MPI Main File
52/75
L1: SHR BL,1
XOR AL,BL
DEC CL
JNZ L1
INC SI
MOV [SI], AL
HLT
Assembly Language Program:-
Program
address
Opcode Mnemonics Comments
0100
0103
0105
0107
0109
010B
010D
010F
0111
0112
0114
BE0002
B108
8A04
88C3
D0EB
30D8
FEC9
75F8
46
8804
F4
MOV SI,0200
MOV CL,08
MOV AL,[SI]
MOV BL,AL
SHR BL,1
XOR AL,BL
DEC CL
JNZ 0109
INC SI
MOV [SI],AL
HLT
Initialize SI.
Move 08 to CL
Move contents of SI to AL.
Move AL to BL.
Shift Right BL by 1 bit.
AL EX OR BL
Decrement CL.
If CL=0 continue, else jump to 0109.
Increment SI.
Move AL to contents of SI.
End of the program.
Algorithm:-
Start
SI 0200
DI 0300
CX 0005
DX 0000
L2: AL [SI]
BL [DI]
Compare AL with BL.
If AL = BL jump to L1, else continue.
DX DX+1
L1: SI SI+1
DI DI+1
If CX =0 continue else jump to L2Stop
-
8/9/2019 MPI Main File
53/75
Reference table:-
Memory Location Data
0200 Data1
0201 Data20202 Data3
0203 Data4
0204 Data5
0300 Data1
0301 Data2
0302 Data3
0303 Data4
0304 Data 5
Result table:-
Memory Location Data
0200 01 H
0201 02 H
0202 03 H
0203 04 H
0204 05 H
0300 01 H
0301 02 H0302 04 H
0303 05 H
0304 05 H
Result: - After Comparison DL=02. ZF=1.
String Comparison
Aim: -To write an assembly language program to compare strings.
Program:-
MOV SI,0200
MOV DI,0300
MOV CX,0005
MOV DX,0000
L2: MOV AL,[SI]
MOV BL, [DI]
CMP AL, BLJE L1
-
8/9/2019 MPI Main File
54/75
INC DX
L1: INC SI
INC DI
LOOP L2
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0106
0109
010C
010E
0110
0112
0114
0115
0116
0117
0119
BE0002
BF0003
B90500
BA0000
8A04
8A1D
38D8
7401
42
46
47
E2F3
F4
MOV SI,0200
MOV DI,0300
MOV CX,0005
MOV DX,0000
MOV AL,[SI]
MOV BL,[DI]
CMP AL,BL
JZ 0115
INC DX
INC SI
INC DI
LOOP 010C
HLT
Initialize SI.
Initialize DI.
Move 05 to CX.
Clear DX.
Move contents of SI to AL.
Move contents of DI to BL
Compare AL and BL.
When AL =BL jump to 0115, else
continue.
Increment DX.
Increment SI.
Increment DI
Loop until CX= 0 through 010c
End of program
Algorithm:-Start
SI 0200
CX 0004
DI 0403
L1: AL [SI]
[DI] AL
SI SI+1
DI DI-1
If CX =0 continue else jump to L1
Stop
Input table:-
Memory Location Input Data
-
8/9/2019 MPI Main File
55/75
0200 01H
0201 02H
0202 03H
0203 04H
Result table:-
Memory Location Output Data
0400 04 H
0401 03 H
0402 02 H
0403 01 H
Result: - String of four numbers has been reversed.
Reverse a String
Aim: -To write an assembly language program to Reverse a string.
Program:-
MOV SI,0200
MOV CX,0004
MOV DI,0403
L1: MOV AL,[SI]
-
8/9/2019 MPI Main File
56/75
MOV [DI],AL
INC SI
DEC DI
LOOP L1
HLT
Assembly Language Program:-
Program address Opcode Mnemonics Comments
0100
0103
0106
0109
010B
010D
010E
010F
0111
BE0002
B90400
BF0304
8A04
8805
46
4F
E2F8
F4
MOV SI,0200
MOV CX,0004
MOV DI,0403
MOV AL,[SI]
MOV [DI],AL
INC SI
DEC DI
LOOP 0109
HLT
Initialize SI.
Move 04 to CL.
Initialize DI.
Move contents of SI to Al.
Move AL to contents of DI.
Increment SI.
Decrement DI.
If CL0 jump to 0109, else continue.
End of program
ALGORITHM:
START
SI 0200
AX [SI]
AX AX*AX
BX 03
AX AX*BX
BX AX
AX [SI]
DX 02
AX AX*DX
BX BX-AX
BX BX+04
AX BX
BX 05
AX
AX/BXSI SI+1
-
8/9/2019 MPI Main File
57/75
SI SI+1
[SI] AX
SI SI+1
SISI+1
[SI] DX
STOP
EVALUATION OF EXPRESSION
AIM: To write an assembly language program for evaluating the expression
(3X^2- 2X+2)/5 for given value of X.
PROGRAM:
MOV SI, 0200
MOV AX, [SI]
MUL AX
MOV BX, 03
MUL BXMOV BX, AX
-
8/9/2019 MPI Main File
58/75
MOV AX, [SI]
MOV DX, 02
MUL DX
SUB BX, AX
ADD BX, 02
MOV AX, BXMOV BX, 05
DIV BX
INC SI
INC SI
MOV [SI], AX
INC SI
INC SI
MOV [SI], DX
HLT
REFERENCE TABLE:
MEMORY LOCATION DATA
0200 DATA(AL)0201 DATA(AH)
0202 RESULT(AL)
0203 RESULT(AH)
RESULT TABLE:
MEMORY LOCATION DATA
0200 02
0201 00
0202 02
0203 00
-
8/9/2019 MPI Main File
59/75
ASSEMBLY LANGUAGE PROGRAM TABLE:
PROGRAM
ADDRESS
OPCODE MNEUMONICS COMMENTS
0100 BE0002 MOV SI, 0200 Initialize memory location 0200
to SI0103 8B04 MOV AX, [SI] Move the contents of SI to AX
0105 F7E0 MUL AX Multiply AX with AX
0107 BB0300 MOV BX, 0003 Move the data 0003 to BX
010A F7E3 MUL BX Multiply BX with AX
010C 89C3 MOV BX, AX Move the data of AX to BX
010E 8B04 MOV AX, [SI] Move the contents of SI to AX
0110 BA0500 MOV DX, 0005 Move the data 0005 to DX
0113 F7E2 MUL DX Multiply DX with AX
0115 29C3 SUB BX, AX Subtract BX from AX& store in
Bx
0117 83C302 ADD BX, 02 Add 02 to the contents of BX
-
8/9/2019 MPI Main File
60/75
011A 89D8 MOV AX, BX Move the data of BX to AX
011C BB0550 MOV BX, 0005 Move the data 0005 to BX
011F F7F3 DIV BX Divide BX by AX
0121 46 INC SI Increment SI
0122 46 INC SI Increment SI
0123 8904 MOV [SI], AX Move AX to the contents of SI0125 46 INC SI Increment SI
0126 46 INC SI Increment SI
0127 8914 MOV [SI], DX Move DX to the contents of SI
0129 F4 HLT End of the program
8051
-
8/9/2019 MPI Main File
61/75
Micro
Controllerprograms
8051 microcontroller
Features & Applications
It provides many functions (CPU, RAM, ROM, I/O, interruptlogic, timer, etc.) in a single package
8-bit data bus - It can access 8 bits of data in one operation(hence it is an 8-bitmicrocontroller)
16-bit address bus - It can access 216 memory locations - 64kB each of RAM and ROM
On-chip RAM - 128 bytes ("Data Memory") On-chip ROM - 4 kB ("Program Memory")
http://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/Random_access_memoryhttp://en.wikipedia.org/wiki/Read-only_memoryhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Interrupthttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Integrated_circuit_packaginghttp://en.wikipedia.org/wiki/Data_bushttp://en.wikipedia.org/wiki/8-bithttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Address_bushttp://en.wikipedia.org/wiki/Kilobytehttp://en.wikipedia.org/wiki/Byteshttp://en.wikipedia.org/wiki/Kilobytehttp://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/Random_access_memoryhttp://en.wikipedia.org/wiki/Read-only_memoryhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Interrupthttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Integrated_circuit_packaginghttp://en.wikipedia.org/wiki/Data_bushttp://en.wikipedia.org/wiki/8-bithttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Address_bushttp://en.wikipedia.org/wiki/Kilobytehttp://en.wikipedia.org/wiki/Byteshttp://en.wikipedia.org/wiki/Kilobyte -
8/9/2019 MPI Main File
62/75
Four byte bi-directional input/output port
UART (serial port)
Two 16-bit Counter/timers
Two-level interrupt priority
Power saving mode
INTRODUCTION TO Keil Vision3 (v3)
Software Development Cycle
When you use the Keil Vision, the project development cycle isroughly the same as it is for any other software developmentproject.
Create a project, select the target chip from the device
database, and configure the tool settings. Create source files in C or assembly.
Build your application with the project manager.
Correct errors in source files.
Test the linked application.
Vision IDE
The Vision IDE combines project management, a rich-featured editor with interactive error correction, option setup, makefacility, and on-line help. Use Vision to create your source files andorganize them into a project that defines your target application.Vision automatically compiles, assembles, and links yourembedded application and provides a single focal point for yourdevelopment efforts.
C51 Compiler & A51 Macro Assembler
Source files are created by the Vision IDE and are passed tothe C51 Compiler or A51 Macro Assembler. The compiler andassembler process source files and create relocatable object files.
The Keil C51 Compiler is a full ANSI implementation of the Cprogramming language that supports all standard features of the Clanguage. In addition, numerous features for direct support of the8051 architecture have been added. The Keil A51 macro assemblersupports the complete instruction set of the 8051 and allderivatives.
Start Vision
Create a Project File
To create a new project file select from the Vision menu:Project New Project- This opens a standard Windows dialog that
http://en.wikipedia.org/wiki/Bytehttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Interrupthttp://en.wikipedia.org/wiki/Power_managementhttp://en.wikipedia.org/wiki/Bytehttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Interrupthttp://en.wikipedia.org/wiki/Power_management -
8/9/2019 MPI Main File
63/75
asks you for the new project file name. Use a separate folder foreach project. Vision creates a new project file with the nameNAME.UV2 which contains a default target and file group name. Youcan see these names in the Project Workspace Files.
Select a Device
When you create a new project Vision asks you to select aCPU for your project. The Select Device dialog box shows theVision device database. Just select the microcontroller you use.Example shows the AT89C51 controller. This selection setsnecessary tool options for the AT89C51 device and simplifies in thisway the tool configuration. When you create a new project, Visionmay automatically add the correct device specific CPU startup codefor you.
Create New Source Files
You may create a new source file with the menu option File New. This opens an empty editor window where you can enter yoursource code. Vision enables the C color syntax highlighting whenyou save your file with the dialog File Save As under a filenamewith the extension *.asm. We are saving our example file under thename MAIN.asm.
Once you have created your source file you can add this file
to your project. Vision offers several ways to add source files to aproject. For example, you can select the file group in the Project
-
8/9/2019 MPI Main File
64/75
Workspace Files page and click with the right mouse key to open alocal menu. The option Add Files opens the standard files dialog.Select the file MAIN.asm you have just created.
Add and Configure the Startup Code
The STARTUP.A51 file is the startup code for the most 8051 CPUvariants. The startup code clears the data memory and initializeshardware and reentrant stack pointers. In addition, some 8051derivatives require a CPU initialization code that needs to match the
configuration of your hardware design.
Group Project Files
File group allow you to organize large projects. For the CPU startupcode and other system configuration files you may create a own filegroup in the Project Components, Environment, Books dialogbox. Use the New (Insert) button to create a file group namedSystem Files. In the project window you may drag and drop theSTARTUP.A51 file to this new file group.
-
8/9/2019 MPI Main File
65/75
Now, the Project Workspace Files lists all items of yourproject. To open a file for editing, double click on the file name inthe Project Workspace. You may need to configure the startupSTARTUP.A51 in the editor.
Set Tool Options for Target
Vision lets you set options for your target hardware. The dialogOptions for Target opens via the toolbar icon or via the Project -Options for Target menu item. In the Target tab you specify allrelevant parameters of your target hardware and the on-chipcomponents of the device you have selected. The following are thesettings for our example are shown.
-
8/9/2019 MPI Main File
66/75
-
8/9/2019 MPI Main File
67/75
the application with a click on the Build Target toolbar icon. Whenyou build an application with syntax errors, Vision will displayerrors and warning messages in the Output Window Build page. Adouble click on a message line opens the source file on the correctlocation in a Vision editor window.
Once you have successfully generated your application you
can start debugging, now you may modify existing source code oradd new source files to the project. The Build Target toolbar buttontranslates only modified or new source files and generates theexecutable file. Vision maintains a file dependency list and knowsall include files used within a source file. Even the tool options aresaved in the file dependency list, so that Vision rebuilds files onlywhen needed. With the Rebuild Target command, all source files aretranslated, regardless of modifications.
After you have tested your application, it might be required tocreate an Intel HEX file and to download the application software
into the physical device using a Flash programming utility. Visioncreates HEX files with each build process when Create HEX fileunder Options for Target Output is enabled.
-
8/9/2019 MPI Main File
68/75
Overview of Options Dialogs
The Project - Options dialog pages let you set all the tool options. Alloptions are saved in the Vision project file Via the local menu inthe Project Workspace Files you may set different options for a filegroup or even a single file. In this case you may have an additionalProperties page and only dialog pages that are related to theselected item.
The following table gives an overview of the various optionsdialogs.
DialogPage
Description
Target Specify the hardware of your application.
Output Define the output files of the tool chain and allows you to start userprograms after the build process.
Listing Specify all listing files generated by the tool chain.
C51, CX51 Set C51 Compiler specific tool options like code optimization orvariable allocation.
A51, AX51 Set Assembler specific tool options like macro processing.
BL51LocateLX51 Locate
Define the location of memory classes and segments. Typical you willenable Use Memory Layout from Target Dialog as shown below to getautomatic settings.
BL51 MiscLX51 Misc
Other linker related settings like Warning or memory Reservedirective.
-
8/9/2019 MPI Main File
69/75
Debug Settings for the Vision Debugger.
Properties File information and special options for files and groups.
Start Debug ModeYou start the debug mode of Vision with the Debug
Start/Stop Debug Session command. Depending on the Options forTarget Debug configuration, Vision will load the applicationprogram and run the startup code. Vision saves the editor screenlayout and restores the screen layout of the last debug session. Ifthe program execution stops, Vision opens an editor window withthe source text or shows CPU instructions in the disassemblywindow. The next executable statement is marked with a yellowarrow.
Debug Windows and DialogsVision provides several windows and dialogs that aid during
the debugging phase. The windows and dialogs open via toolbarbuttons or the Vision menu.
Toolbar
Menu Item and Description
Debug Breakpoint... (Ctrl+B): set, reviewed, or modified Access,Conditional, or Execution breakpoints.
View Code Coverage Window: statistics for code that has beenexecuted.
View Project Workspace Regs Tab: show or modify CPU registercontents.
View Disassembly Window: assembly instructions or trace historyintermixed with source code.
View Logic Analyzer Window: graphic display of variable or I/Ochanges.
View Memory Window: review or modify memory contents.
Debug Memory Map...: specify memory areas for data and programcode.
View Output Window Debug Tab: enterdebug commands,expressions or invoke debug functions.
View Performance Analyzer Window: timing statistic of programexecution.
View Serial Window 1 - 3: terminal window for serial input/output.
View Symbol Window: list symbolic program information.
View Toolbox: user-configurable buttons for quick command execution.
View Watch & Call Stack Window: view and modify variables and listsfunction call nesting.
AIM: To write a program for LED Blinking for LEDs those are connected to port-1
PROGRAM:
-
8/9/2019 MPI Main File
70/75
ORG 0000h
back : Mov a,#55h
Mov p1,a
Lcall delay
Mov a,#0AAh
Mov p1,aLcall delay
Sjmp back
Delay : Mov R5,#05h
Again :Djnz R5,Again
Ret
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to Toggle all bits of port-P1
PROGRAM:
ORG 0000h
-
8/9/2019 MPI Main File
71/75
Back : Mov a,#0FFh
Mov p1,a
Lcall delay
Mov a,#0FEh
Mov p1,a
Lcall delaySjmp Back
Delay: Mov R5,#05h
Again: Djnz R5,Again
Ret
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to get a byte of data from p0 and
Send it to p1
PROGRAM:
-
8/9/2019 MPI Main File
72/75
ORG 0000h
Mov R0,#55h
Mov P0,R0
Mov P1,P0
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to transmit A serially at 9600
baud rate
PROGRAM:
ORG 0000h
Mov TMOD, #20hMov SCON, #50h
-
8/9/2019 MPI Main File
73/75
Mov TH1, #-3h
Setb TR1
Again: Mov SBUF, #A
Here : Jnb TI,Here
clr TI
sjmp Againend
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to transmit ECE serially at 4800
baud rate
PROGRAM:
ORG 000hMov TMOD,#20h
-
8/9/2019 MPI Main File
74/75
Mov SCON,#50h
Mov TH1,#-6h
Setb TR1
Again: Mov A,#'E'
Acall trans
Mov A,#'C'Acall trans
Mov A,#'E'
Acall trans
Mov A,#' '
Acall trans
Sjmp Again
Trans : Mov Sbuf,A
Here : Jnb TI,Here
Clr TI
RET
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to receive data serially at 9600
baud rate
PROGRAM:
ORG 000h
Mov TMOD,#20h
Mov SCON,#50h
Mov TH1,#-3h
-
8/9/2019 MPI Main File
75/75
Setb TR1
Here : Jnb Ri,Here
Mov A,Sbuf
Mov P1,A
Clr Ri
Sjmp HereEnd
OUTPUT:
top related