Вы находитесь на странице: 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 VCT
INT key.
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 a
microprocessor 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 a
run 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 each
having 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 trainer
kit.
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 Data2
0202 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


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 Comments


0100 BE0002 MOV SI,0200 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 46 INC SI Increment SI.
0106 8A1C MOV BL,[SI] Move contents of SI to BL.
0108 00D8 ADD AL,BL Add AL and BL.
010A 46 INC SI Increment SI.
010B 8804 MOV [SI],AL Move AL to contents of SI.
010D F4 HLT End of the program.

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 Data2
0202 Result

Result table:-
Memory Location Data
0200 56 H
0201 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.


Program:-

MOV SI, 0200


MOV 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 BE0002 MOV SI,0200 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 46 INC SI Increment SI.
0106 8A1C MOV BL,[SI] Move contents of SI to BL.
0108 28D8 SUB AL,BL Subtract BL from Al.
010A 46 INC SI Increment SI.
010B 8804 MOV [SI],AL Move AL to contents of SI.
010D F4 HLT 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
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
0203 Result

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;
AL←00
AH←02

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 SI
MOV BL, [SI]
MUL BL
INC SI
MOV [SI], AL
INC SI
MOV [SI], AH
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0002 MOV SI,0200 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 46 INC SI Increment SI.
0106 8A1C MOV BL,[SI] Move contents of SI to BL.
0108 F6E3 MUL BL Multiply AL and BL
010A 46 INC SI Increment SI.
010B 8804 MOV [SI],AL Move AL to contents of SI.
010D 46 INC SI Increment SI
010E 8824 MOV [SI], AH Move AH to contents of SI
0110 F4 HLT 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
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
0203 Result

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, 0200


MOV AL, [SI]
INC SI
MOV BL, [SI]
DIV BL
INC SI
MOV [SI], AL
INC SI
MOV [SI], AH
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0002 MOV SI,0200 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 46 INC SI Increment SI.
0106 8A1C MOV BL,[SI] Move contents of SI to BL.
0108 F6F3 DIV BL Divide AL by BL.
010A 46 INC SI Increment SI.
010B 8804 MOV [SI],AL Move AL to contents of SI.
010D 46 INC SI Increment SI
010E 8824 MOV [SI], AH Move AH to contents of SI
0110 F4 HLT 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
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:-


Program address Opcode Mnemonics Comments
0100 BE0004 MOV SI,0400 Initialize SI.
0103 8B04 MOV AX, [SI] Move contents of SI to AX.
0105 46 INC SI Increment SI.
0106 46 INC SI Increment SI.
0107 8B1C MOV BX, [SI] Move contents of SI to BX.
0109 01D8 ADD AX, BX Add AX and BX.
010B 46 INC SI Increment SI.
010C 46 INC SI Increment SI.
010D 8904 MOV [SI], AX Move AX to contents of SI.
010F F4 HLT 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
0404 Result
0405

Result table:-

Memory Location Data


0400 A2 H
0401 D3 H
0402 41 H
0403 BC H
0404 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 SI
MOV [SI], AX
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0004 MOV SI,0400 Initialize SI.
0103 8B04 MOV AX, [SI] Move contents of SI to AX.
0105 46 INC SI Increment SI.
0106 46 INC SI Increment SI.
0107 8B1C MOV BX, [SI] Move contents of SI to BX.
0109 29D8 SUB AX, BX Subtract BX from AX.
010B 46 INC SI Increment SI.
010C 46 INC SI Increment SI.
010D 8904 MOV [SI], AX Move AX to contents of SI.
010F F4 HLT 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
SI ← SI+1
SI ←SI+1
[SI] ← AX
Stop

Reference table:-

Memory Location Data


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 SI
INC SI
MOV [SI], DX
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0004 MOV SI,0400 Initialize SI.
0103 8B04 MOV AX,[SI] Move contents of SI to AX.
0105 46 INC SI Increment SI.
0106 46 INC SI Increment SI.
0107 8B1C MOV BX,[SI] Move contents of SI to BX.
0109 F7E3 MUL BX Multiply AX and BX.
010B 46 INC SI Increment SI.
010C 46 INC SI Increment SI.
010D 8904 MOV [SI],AX Move AX to contents of SI.
010F 46 INC SI Increment SI.
0110 46 INC SI Increment SI.
0111 8914 MOV [SI],DX Move DX to contents of SI.
0113 F4 HLT 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
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, 0400


MOV 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
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0004 MOV SI,0400 Initialize SI.
0103 8B04 MOV AX, [SI] Move contents of SI to AX.
0105 46 INC SI Increment SI.
0106 46 INC SI Increment SI.
0107 8B1C MOV BX, [SI] Move contents of SI to BX.
0109 F7F3 DIV BX Divide AX by BX.
010B 46 INC SI Increment SI.
010C 46 INC SI Increment SI.
010D 8904 MOV [SI], AX Move AX to contents of SI.
010F 46 INC SI Increment SI.
0110 46 INC SI Increment SI.
0111 8914 MOV [SI],DX Move DX to contents of SI.
0113 F4 HLT 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
Stop

Reference table:-
Memory Location Data
0500 Data1
0501 Data2
0502 Result

Result table:-
Memory Location Data
0500 87
0501 63
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:-


Program address Opcode Mnemonics Comments
0100 BE0005 MOV SI,0500 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 46 INC SI Increment SI.
0106 8A1C MOV BL,[SI] Move contents of SI to BL.
0108 00D8 ADD AL,BL Add AL and BL.
010A 27 DAA Decimal adjust after addition.
010B 46 INC SI Increment SI.
010C 8804 MOV [SI],AL Move AL to contents of SI.
010E F4 HLT 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]  AL
STOP

REFERENCE TABLE:

MEMORY LOCATION DATA

0500 DATA1(AL)
0501 DATA2(BL)
0502 RESULT(AL)
0503 RESULT(BL)
RESULT TABLE:

MEMORY LOCATION DATA

0500 36
0501 34
0502 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,BL
AAA
INC SI
MOV [SI],AL
INC SI
MOV [SI],AH
HLT

ASSEMBLY LANGUAGE PROGRAM TABLE:


PROGRAM OPCODE MNEUMONICS COMMENTS
ADDRESS
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 SI
0106 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 06H
0203 DATA4 03H
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:


PROGRAM OPCODE MNEUMONICS COMMENTS
ADDRESS
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 CL
0107 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 Data


0600 Data1
0601 Data2

Result table:-

Memory Location Data


0600 AD
0601 52

Result: - AL= AD
After complementing AL= 52;

1’s complement of a 8 bit number

Aim: - To write an assembly language program to Find 1’s 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


0100 BE0006 MOV SI,0600 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 F6D0 NOT AL Complement AL.
0107 46 INC SI Increment SI.
0108 8804 MOV [SI],AL Move AL to contents of SI.
010A F4 HLT 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:-
Memory Location Data
0600 FD H
0601 03 H

Result: - AL= AD
After complementing AL= 52;

2’s complement of a 8 bit number

Aim: - To write an assembly language program to Find 2’s 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


0100 BE0006 MOV SI,0600 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 F6D0 NEG AL Complement AL and ADD 1
0107 46 INC SI Increment SI.
0108 8804 MOV [SI],AL Move AL to contents of SI.
010A F4 HLT 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 Data1
0601 Data2
Result table:-
Memory Location Data
0600 05 H
0601 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


0100 BE0006 MOV SI,0600 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 88C3 MOV BL,AL Move AL to BL.
0107 FECB DEC BL Decrement BL.
0109 F6E3 MUL BL Multiply BL With AL.
010B FECB DEC BL Decrement BL.
010D 75FA JNZ 0109 Jump Non Zero (If ZF = 1
continue, else jump to 0109).
010F 46 INC SI Increment SI.
0110 8804 MOV [SI],AL Move AL to contents of SI.
0112 F4 HLT 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 ↔AL
Call SUBROUTINE PROGRAM

AL ↔ BL
BL ↔ AL

Call SUBROUTINE PROGRAM

AL ← AL*DL

AL ↔ BL
AL ← AL/BL
SI ← SI+1
[SI] ← AL
Stop

n
COMPUTE Cr

Aim: - To write an assembly language program to find Number of Combinations by


n
Using the formula of Cr .

Program:-

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

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.


5
C3 = 0A H.
Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 88C1 MOV CL,AL Move AL to CL.
0102 FEC9 DEC CL Decrement CL.
0104 F6E1 MUL CL Multiply AL and CL.
0106 FEC9 DEC CL Decrement CL.
0108 75FA JNZ 0104 (Jump Non Zero) If ZF =1
Continue, Else Jump to 0104.

010A C3 RET Return to Called Location.

010B BE0004 MOV SI,0400 Initialize SI.

010E 8A04 MOV AL,[SI] Move contents of SI to AL.

0110 46 INC SI Increment SI.

0111 8A1C MOV BL,[SI] Move contents of SI to BL.

0113 88C2 MOV DL,AL Move AL to DL.

0115 28D8 SUB AL,BL Subtract BL from AL.

0117 E8E6FF CALL 0100 Call Label 0100.

011A 86C2 XCHG AL,DL Exchange AL and DL.

011C E8E1FF CALL 0100 Call label 0100

011F 86C3 XCHG AL,BL Exchange AL and BL.

0121 E8DCFF CALL 0100 Call Label 0100

0124 F6E2 MUL DL Multiply AL and DL.

0126 86C3 XCHG AL,BL Exchange AL and BL.

0128 F6F3 DIV BL Divide AL by BL.

012A 46 INC SI Increment SI.

012B 8804 MOV [SI],AL Move AL to contents of SI.

012D F4 HLT End of the program.


Algorithm:-
Start
DX ← 0003
L1: DI ← 0200
CX ← 0005
L2: 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
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
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


0100 BA0300 MOV DX,0003 Move 03 to DX.
0103 BF0002 MOV DI,0200 Initialize DI.
0106 B90300 MOV CX,0003 Move 03 to CX.
0109 8A05 MOV AL,[DI] Move contents of DI to AL.
010B 3A4501 CMP AL,[DI+01] Compare AL & [DI + 01]
010E 7C05 JL 0115 If AL < [DI+01] Then jump
to 0115, else continue.

0110 864501 XCHG AL, [DI+01] Exchange AL, [DI + 01]


0113 8805 MOV [DI],AL Move AL to contents of DI.
0115 47 INC DI Increment DI.
0116 E2F1 LOOP 0109 Loop: Jump to 0109 if CX ≠
0, else continue.
0118 4A DEC DX Decrement DX.
0119 89D1 MOV CX,DX Move DX to CX.
011B E2E6 LOOP 0103 Loop: Jump to 0103 if CX ≠
0, else continue.
011D F4 HLT End of the program.

Algorithm:-
Start
DX ← 0003
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
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 L3
XCHG AL, [DI+01]
MOV [DI], AL
L3: INC DI
LOOP L2
DEC DX
MOV CX, DX
LOOP L1
HLT
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 86H
0202 57H
0203 34H
0204 29H

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BA0300 MOV DX,0003 Move 03 to DX.
0103 BF0002 MOV DI,0200 Initialize DI.
0106 B90300 MOV CX,0003 Move 03 to CX.
0109 8A05 MOV AL,[DI] Move contents of DI to AL.
010B 3A4501 CMP AL,[DI+01] Compare AL & [DI + 01]
010E 7F05 JG 0115 If AL > [DI+01] Then jump to
0115, else continue.

0110 864501 XCHG AL, [DI+01] Exchange AL, [DI + 01]


0113 8805 MOV [DI],AL Move AL to contents of DI.
0115 47 INC DI Increment DI.
0116 E2F1 LOOP 0109 Loop: Jump to 0109 if CX ≠
0, else continue.
0118 4A DEC DX Decrement DX.
0119 89D1 MOV CX,DX Move DX to CX.
011B E2E6 LOOP 0103 Loop: Jump to 0103 if CX ≠
0, else continue.
011D F4 HLT End of the program.

Algorithm:-
Start
SI ← 0200
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.
Program:-

MOV SI,0200
MOV AL,[SI]
MOV CL, 08
L1: RCR AL, 1
JNC L2
INC BL
L2: LOOP L1
HLT
Assembly Language Program:-

Program Opcode Mnemonics Comments


address
0100 BE0002 MOV SI,0200 Initialize SI
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 B108 MOV CL,08 Move 08 to CL.
0107 D0D8 RCR AL,1 Rotate Right AL by one bit.
0109 7302 JNB 010D Jump Non Carry to the Label. (If CF
is set continue, else jump to L2.)
010B FEC3 INC BL Increment BL.
010D E2F8 LOOP 0107 If CX=0 continue, else jump to
0107.
010F F4 HLT End of the Program.

Algorithm:-

Start
SI ←0200
CX ←0008
DI ←0220
Clear direction flag
Prefix of MOVSB repeat MOVSB until CL=0 or ZF≠0.
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 H
0221 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 string
instructions.
Program:-

MOV SI,0200
MOV CX,0008
MOV DI ,0220
CLD
REPZ
MOVSB
HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0002 MOV SI,0200 Initialize SI.

0103 B90800 MOV CX,0008 Move 08 to CL.

0106 BF2002 MOV DI,0220 Initialize DI.

0109 FC CLD Clear direction flag.

010A F3 REPZ Prefix of MOVSB repeat MOVSB until


CL=0 or ZF≠0.
010B A4 MOVSB Move byte or word from one string to
another.
010C F4 HLT End of program

Algorithm:-

Start
SI ← 0200
CX ← 000A
AL ← [SI]
L1: AL ← [0200]
BL ← BL+1
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 Table
0206
0207
0208
0209
020A
Result table:-

Memory Location Data


0200 03 H
0201 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 H
020A 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 given


number.

Program:-
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 BE0002 MOV SI,0200 Initialize SI.

0103 B90A00 MOV CX,000A Move 0A to CX.

0106 8A04 MOV AL,[SI] Move contents of Si to AL.

0108 A00002 MOV AL,[0200] Move [0200] to AL.

010B FEC3 INC BL Increment BL.

010D F6E3 MUL BL Multiply BL with AL.

010F 46 INC SI Increment SI.

0110 8804 MOV [SI],AL Move AL to contents of Si

0112 E2F4 LOOP 0108 Jump to 0108 until CX=0.

0114 F4 HLT End of program


Algorithm:-
Start
SI ← 0200
AL ← [SI]
BL ← AL
Shift bits of BL to Right.
AL ← AL* BL
SI ← SI+1
[SI] ←AL
Stop

Reference table:-

Memory Location Data


0200 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:-
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 BE0002 MOV SI,0200 Initialize SI.
0103 8A04 MOV AL,[SI] Move contents of SI to AL.
0105 88C3 MOV BL,AL Move AL to BL.
0107 D0EB SHR BL,1 Shift Right BL by 1 bit.
0109 30D8 XOR AL,BL AL EX OR BL
010B 46 INC SI Increment SI.
010C 8804 MOV [SI],AL Move AL to contents of SI.
010E F4 HLT End of the program.

Algorithm:-

Start
SI ← 0200
AL ← [SI]
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
L1: SHR BL,1
XOR AL,BL
DEC CL
JNZ L1
INC SI
MOV [SI], AL
HLT

Assembly Language Program:-


Program Opcode Mnemonics Comments
address
0100 BE0002 MOV SI,0200 Initialize SI.
0103 B108 MOV CL,08 Move 08 to CL
0105 8A04 MOV AL,[SI] Move contents of SI to AL.
0107 88C3 MOV BL,AL Move AL to BL.
0109 D0EB SHR BL,1 Shift Right BL by 1 bit.
010B 30D8 XOR AL,BL AL EX OR BL
010D FEC9 DEC CL Decrement CL.
010F 75F8 JNZ 0109 If CL=0 continue, else jump to 0109.
0111 46 INC SI Increment SI.
0112 8804 MOV [SI],AL Move AL to contents of SI.
0114 F4 HLT 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 L2
Stop
Reference table:-

Memory Location Data


0200 Data1
0201 Data2
0202 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 H
0302 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, BL
JE L1
INC DX
L1: INC SI
INC DI
LOOP L2
HLT
Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0002 MOV SI,0200 Initialize SI.

0103 BF0003 MOV DI,0300 Initialize DI.

0106 B90500 MOV CX,0005 Move 05 to CX.

0109 BA0000 MOV DX,0000 Clear DX.

010C 8A04 MOV AL,[SI] Move contents of SI to AL.

010E 8A1D MOV BL,[DI] Move contents of DI to BL

0110 38D8 CMP AL,BL Compare AL and BL.

0112 7401 JZ 0115 When AL =BL jump to 0115, else


continue.
0114 42 INC DX
Increment DX.
0115 46 INC SI
Increment SI.
0116 47 INC DI
Increment DI
0117 E2F3 LOOP 010C Loop until CX= 0 through 010c
0119 F4 HLT 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


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]


MOV [DI],AL

INC SI

DEC DI

LOOP L1

HLT

Assembly Language Program:-

Program address Opcode Mnemonics Comments


0100 BE0002 MOV SI,0200 Initialize SI.

0103 B90400 MOV CX,0004 Move 04 to CL.

0106 BF0304 MOV DI,0403 Initialize DI.

0109 8A04 MOV AL,[SI] Move contents of SI to Al.

010B 8805 MOV [DI],AL Move AL to contents of DI.

010D 46 INC SI Increment SI.

010E 4F DEC DI Decrement DI.

010F E2F8 LOOP 0109 If CL≠0 jump to 0109, else continue.

0111 F4 HLT 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/BX
SI  SI+1
SI  SI+1
[SI]  AX
SI  SI+1
SI SI+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 BX
MOV BX, AX
MOV AX, [SI]
MOV DX, 02
MUL DX
SUB BX, AX
ADD BX, 02
MOV AX, BX
MOV 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
ASSEMBLY LANGUAGE PROGRAM TABLE:

PROGRAM OPCODE MNEUMONICS COMMENTS


ADDRESS
0100 BE0002 MOV SI, 0200 Initialize memory location 0200
to SI
0103 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
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 SI
0125 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
Micro
Controller
programs

8051 microcontroller

Features & Applications

 It provides many functions (CPU, RAM, ROM, I/O, interrupt


logic, 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-bit microcontroller)
 16-bit address bus - It can access 216 memory locations - 64
kB each of RAM and ROM
 On-chip RAM - 128 bytes ("Data Memory")
 On-chip ROM - 4 kB ("Program Memory")
 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 is
roughly the same as it is for any other software development
project.
 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, make
facility, and on-line help. Use µVision to create your source files and
organize them into a project that defines your target application.
µVision automatically compiles, assembles, and links your
embedded application and provides a single focal point for your
development efforts.

C51 Compiler & A51 Macro Assembler

Source files are created by the µVision IDE and are passed to
the C51 Compiler or A51 Macro Assembler. The compiler and
assembler process source files and create relocatable object files.
The Keil C51 Compiler is a full ANSI implementation of the C
programming language that supports all standard features of the C
language. In addition, numerous features for direct support of the
8051 architecture have been added. The Keil A51 macro assembler
supports the complete instruction set of the 8051 and all
derivatives.

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
asks you for the new project file name. Use a separate folder for
each project. µVision creates a new project file with the name
NAME.UV2 which contains a default target and file group name. You
can see these names in the Project Workspace – Files.

Select a Device

When you create a new project µVision asks you to select a


CPU for your project. The Select Device dialog box shows the
µVision device database. Just select the microcontroller you use.
Example shows the AT89C51 controller. This selection sets
necessary tool options for the AT89C51 device and simplifies in this
way the tool configuration. When you create a new project, µVision
may automatically add the correct device specific CPU startup code
for 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 your
source code. µVision enables the C color syntax highlighting when
you save your file with the dialog File – Save As… under a filename
with the extension *.asm. We are saving our example file under the
name 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 a
project. For example, you can select the file group in the Project
Workspace – Files page and click with the right mouse key to open a
local 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 CPU
variants. The startup code clears the data memory and initializes
hardware and reentrant stack pointers. In addition, some 8051
derivatives 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 startup
code and other system configuration files you may create a own file
group in the Project – Components, Environment, Books… dialog
box. Use the New (Insert) button to create a file group named
System Files. In the project window you may drag and drop the
STARTUP.A51 file to this new file group.
Now, the Project Workspace – Files lists all items of your
project. To open a file for editing, double click on the file name in
the Project Workspace. You may need to configure the startup
STARTUP.A51 in the editor.

Set Tool Options for Target

µVision lets you set options for your target hardware. The dialog
Options for Target opens via the toolbar icon or via the Project -
Options for Target menu item. In the Target tab you specify all
relevant parameters of your target hardware and the on-chip
components of the device you have selected. The following are the
settings for our example are shown.
The following table describes the options of the Target dialog:

Dialog Item Description


Xtal Specifies the CPU clock of your device. In most cases this
value is identical with the XTAL frequency.
Memory Model Specifies the C51 Compiler memory model. For starting new
applications the default SMALL is a good choice. Refer to
"Memory Models and Memory Types" section for a discussion
of the various memory models.
Allocate Specifies the usage of the on-chip components that are
OnChip... typically enabled in the CPU startup code. If you are using
Use multiple on-chip xdata RAM (XRAM) you should also enable the XRAM
DPTR registers access in the STARTUP.A51 file.
Off- Here you specify all external memory areas of the target
chip...Memory hardware.
Code Banking Specifies the parameters for code and xdata banking. Refer
Xdata Banking to the "Code Banking" section for more information.

Build Project and Create a HEX File

Typical, the tool settings under Options – Target are all you need to
start a new application. You may translate all source files and line
the application with a click on the Build Target toolbar icon. When
you build an application with syntax errors, µVision will display
errors and warning messages in the Output Window – Build page. A
double click on a message line opens the source file on the correct
location in a µVision editor window.

Once you have successfully generated your application you


can start debugging, now you may modify existing source code or
add new source files to the project. The Build Target toolbar button
translates only modified or new source files and generates the
executable file. µVision maintains a file dependency list and knows
all include files used within a source file. Even the tool options are
saved in the file dependency list, so that µVision rebuilds files only
when needed. With the Rebuild Target command, all source files are
translated, regardless of modifications.

After you have tested your application, it might be required to


create an Intel HEX file and to download the application software
into the physical device using a Flash programming utility. µVision
creates HEX files with each build process when Create HEX file
under Options for Target – Output is enabled.
Overview of Options Dialogs

The Project - Options dialog pages let you set all the tool options. All
options are saved in the µVision project file Via the local menu in
the Project Workspace – Files you may set different options for a file
group or even a single file. In this case you may have an additional
Properties page and only dialog pages that are related to the
selected item.

The following table gives an overview of the various options


dialogs.

Dialog Description
Page
Target Specify the hardware of your application.
Output Define the output files of the tool chain and allows you to start user
programs 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 or
variable allocation.
A51, AX51 Set Assembler specific tool options like macro processing.
BL51 Define the location of memory classes and segments. Typical you will
Locate enable Use Memory Layout from Target Dialog as shown below to get
LX51 Loca automatic settings.
te
BL51 Misc Other linker related settings like Warning or memory Reserve
LX51 Misc directive.
Debug Settings for the µVision Debugger.
Properties File information and special options for files and groups.

Start Debug Mode


You start the debug mode of µVision with the Debug –
Start/Stop Debug Session command. Depending on the Options for
Target – Debug configuration, µVision will load the application
program and run the startup code. µVision saves the editor screen
layout and restores the screen layout of the last debug session. If
the program execution stops, µVision opens an editor window with
the source text or shows CPU instructions in the disassembly
window. The next executable statement is marked with a yellow
arrow.

Debug Windows and Dialogs


µVision provides several windows and dialogs that aid during
the debugging phase. The windows and dialogs open via toolbar
buttons or the µVision menu.

Toolba Menu Item and Description


r
Debug — Breakpoint... (Ctrl+B): set, reviewed, or modified Access,
Conditional, or Execution breakpoints.
View — Code Coverage Window: statistics for code that has been
executed.
View — Project Workspace — Regs Tab: show or modify CPU register
contents.
View — Disassembly Window: assembly instructions or trace history
intermixed with source code.
View — Logic Analyzer Window: graphic display of variable or I/O
changes.
View — Memory Window: review or modify memory contents.
Debug — Memory Map...: specify memory areas for data and program
code.
View — Output Window — Debug Tab: enter debug commands,
expressions or invoke debug functions.
View — Performance Analyzer Window: timing statistic of program
execution.
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 lists
function call nesting.

AIM: To write a program for LED Blinking for LEDs those are connected to port-1

PROGRAM:
ORG 0000h
back : Mov a,#55h
Mov p1,a
Lcall delay
Mov a,#0AAh
Mov p1,a
Lcall 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
Back : Mov a,#0FFh
Mov p1,a
Lcall delay
Mov a,#0FEh
Mov p1,a
Lcall delay
Sjmp 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:
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, #20h
Mov SCON, #50h
Mov TH1, #-3h
Setb TR1
Again: Mov SBUF, #’A’
Here : Jnb TI,Here
clr TI
sjmp Again
end

OUTPUT:

AIM: Write a program for 8051 Micro-Controller to transmit ‘ECE’ serially at 4800
baud rate

PROGRAM:

ORG 000h
Mov TMOD,#20h
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
Setb TR1
Here : Jnb Ri,Here
Mov A,Sbuf
Mov P1,A
Clr Ri
Sjmp Here
End

OUTPUT:

Вам также может понравиться