R20 MPMC
R20 MPMC
DEPARTMENT
OF
ELECTRONICS AND COMMUNICATION ENGINEERING
Prepared by
Dr.D.SRIHARI M.E, Ph.D
Department of ECE
LIST OF EXPERIMENTS
(Minimum 12 experiments to be conducted)
PART-A
8086 Microprocessor Programs using MASM/TASM Software:
(Minimum 07 experiments to be conducted)
By using Arithmetic & Logical instructions:
1. Study of MASM/TASM Software.
2. ALP s (8086) for addition and subtraction.
3. ALP s (8086) for multiplication and Division.
4. ALP s (8086) to determine LCM and GCD of two 16-bit numbers.
5. ALP s (8086) to evaluate arithmetic expressions.
6. ALP s (8086) for sorting and searching.
7. Logic operations - Shift and rotate - Converting packed BCD to unpacked BCD, BCD to
ASCII conversion.
By using String Instructions:
8. String operations - Move block, Reverse string, String comparison, Length of string.
9. ALP s (8086) for
i) DOS interrupts
ii) BIOS interrupts
PART-B
(Minimum 02 experiments to be conducted)
Interfacing Programs using 8086:
1. ALP s (8086) for generating ramp wave, triangular wave, and stair case wave forms using
DAC.
2. ALP (8086) for traffic light controller.
3. ALP (8086) for stepper motor control.
PART-C
(Minimum 03 Experiments to be conducted)
8051 Microcontroller:
1. a) ALP (8051) to determine the addition.
b) ALP (8051) to determine the subtraction.
2. a) ALP (8051) to determine the largest of N bytes.
b) ALP (8051) to determine the smallest of N bytes.
3. a) ALP (8051) to multiply a 16-bit number by an 8-bit number.
b) ALP (8051) to find square root of an 8-bit number.
4. a) ALP (8051) to determine LCM of two 8- bit numbers.
b) ALP (8051) to determine GCD of two 8- bit numbers.
5. a) ALP (8051) to generate even numbers.
b) ALP (8051) to generate odd numbers.
6. Timer/Counters (8051) in different modes.
PART-B
ALPs (8086) for generating ramp wave, triangular
wave forms using DAC.
1
ALPs (8086) for generating stair case wave forms
using DAC.
2 ALP (8086) for traffic light controller
INDEX
PART-A
(Minimum 07 experiments to be conducted)
PROGRAM:
. MODEL SMALL
. DATA
COUNT DB 06h
NUMLIST DB 10h,22h,33h,44h,55h,66h
. CODE
MOV AX, @DATA
MOV DS, AX
XOR BX, BX
XOR AX, AX
MOV CL, COUNT
MOV SI, OFFSET NUMLIST
AGAIN: MOV BL, [SI]
ADD AX, BX
INC SI
DEC CL
JNZ AGAIN
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
. CODE
MOV AX, 0F000h
MOV BX, 1000h
ADD AX, BX
MOV CX, AX
MOV AX, 5678h
MOV BX, 1234h
ADC AX, BX
MOV DX, AX
INT 03H
END
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
. CODE
MOV AX, 0111h
MOV BX, 1000h
SUB AX, BX
MOV CX, AX
MOV AX, 5678h
MOV BX, 1234h
SBB AX, BX
MOV DX, AX
INT 03h
END
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
. CODE
MOV AX, -0002h
MOV BL, 80h
IDIV BL
INT 03h
END
INPUT:
OUTPUT:
RESULT:
INPUT 1:
INPUT 2:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
NUM1 DW 003Ch
NUM2 DW 000Fh
GCD DW 01h DUP (?)
. CODE
MOV AX, @DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
BACK: CMP AX, BX
JE RESULT
JNC AHEAD
SUB BX, AX
JMP BACK
AHEAD: SUB AX, BX
JMP BACK
RESULT: MOV GCD, AX
INT 03h
END
INPUT1:
INPUT2:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
NUM1 DW 003Ch
NUM2 DW 000Fh
LCM DW 01h DUP (?)
. CODE
MOV AX, @DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
MOV CX, AX
MOV DX, BX
BACK: CMP AX, BX
JE RESULT
JNC AHEAD
ADD AX, CX
JMP BACK
AHEAD: ADD BX, DX
JMP BACK
RESULT: MOV LCM, AX
INT 03h
END
INPUT1:
INPUT2:
OUTPUT:
RESULT:
Date: Exp. No – 5
ALP (8086) to evaluate arithmetic expressions
AIM: To evaluate a given arithmetic expression f = (a+b) (b+c) (c+d)
(a+b+c+d)
APPARATUS: System with TASM software.
ALGORITHM:
1. Assign Model to the Program.
2. Define the data segment with required variables.
3. Assign Code segment.
4. Initialize DS register with the starting address of data segment through AX register.
5. Copy the variable data a & b into AL & BL and perform the addition between AL & BL.
6. Initialize the starting address of result temporarily with SI register and store the result 1200h
location from the AL register.
7. Copy the variable data b & c into AL & BL and perform the addition between AL & BL.
8. Increment the SI register and store the result 1201h location from the AL register.
9. Copy the variable data c & d into AL & BL and perform the addition between AL & BL.
10. Increment the SI register and store the result 1202h location from the AL register.
11. Copy the variable data a into AL register and perform the addition between AL registers & b.
12. Add the content of AL and c then d to the AL register.
13. Copy the result into BL register from AL register & move the content in 1200h location to AL.
14. Multiply the content in AL with content available in 1201h location then multiply with content
in 1202h location perform the division.
15. Terminate the program by using Break Point Interrupt.
16. End.
PROGRAM:
. MODEL SMALL
. DATA
A DB 01H
B DB 02H
C DB 03H
D DB 04H
. CODE
MOV AX, @DATA
MOV DS, AX
XOR AX, AX
MOV AL, A
MOV BL, B
ADD AL, BL
MOV SI, 1200H
MOV [SI], AL
MOV AL, B
MOV BL, C
ADD AL, BL
INC SI
MOV [SI], AL
MOV AL, C
MOV BL, D
ADD AL, BL
INC SI
MOV [SI], AL
MOV AL, A
ADD AL, B
ADD AL, C
ADD AL, D
MOV CL, AL
XOR AX, AX
INPUT:
OUTPUT:
RESULT:
Date: Exp. No – 6
ALPs (8086) for sorting and searching
(A) Sorting a string in an ascending order
AIM: To sort the given string in an ascending order.
APPARATUS: system with TASM software.
ALGORITHM:
1. Assign Model to the Program.
2. Define the data segment with required variables.
3. Assign code segment.
4. Initialize DS register with the starting address of data segment.
5. Specify the count value for external loop in DL register.
6. Move the offset address of array into SI register.
7. Move the value of DL register into CL register.
8. Move the content of SI register into the AL register.
9. Compare the number in AL register with subsequent number and exchange the position of the
numbers depending on result of the comparison.
10. Repeat step7 until the value present in CL register is Zero.
11. Repeat the steps 5, 6,7and 8 until the DL becomes Zero and observe the results in ascending
order.
12. Terminate the program by using break Point Interrupt.
13. End.
PROGRAM:
. MODEL SMALL
. STACK
. DATA
array db 66H,07H,10H,56H,23H
count db 04H
. CODE
MOV AX, @data
MOV DS, AX
MOV DL, count
a4: MOV SI, offset array
MOV CL, DL
a3: MOV AL, [SI]
CMP AL, [SI+1]
JC a2
XCHG AL, [SI+1]
XCHG AL, [SI]
a2: INC SI
DEC CL
JNZ a3
DEC DL
JNZ a4
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. STACK
. DATA
array db 66H,07H,10H,56H,23H
count db 04H
. CODE
MOV AX, @data
MOV DS, AX
MOV DL, count
a4: MOV SI, offset array
MOV CL, DL
a3: MOV AL, [SI]
CMP AL, [SI+1]
JNC a2
XCHG AL, [SI+1]
XCHG AL, [SI]
a2: INC SI
DEC CL
JNZ a3
DEC DL
JNZ a4
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 02h, 09h, 03h, 06h, 08h, 07h
. CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, OFFSET LIST
MOV CL, 05h
MOV AL, [SI]
UP: INC SI
CMP AL, [SI]
JB GO
MOV AL, [SI]
GO: DEC CL
JNZ UP
INT 03h
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. STACK
. DATA
LIST DB 02h, 09h, 03h, 06h, 08h, 07h
. CODE
MOV AX, @DATA
MOV DS, AX
MOV SI, OFFSET LIST
MOV CL, 05h
XOR AX, AX
MOV AL, [SI]
UP: INC SI
CMP AL, [SI]
JNB GO
MOV AL, [SI]
GO: DEC CL
JNZ UP
INT 03h
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
.DATA
array db 15H,07H,25H,12H
count db 04H
stg db „byte found‟,‟$‟
stg1 db „byte not found‟,‟$‟
.CODE
START: MOV AX, @data
MOV DS, AX
MOV ES, AX
MOV DI, offset array
MOV CL, count
MOV AL, 76H
REPNE SCASB
JZ a2
MOV AH, 09H
LEA DX,stg1
INT 21H
JMP a3
a2: MOV AH, 09H
LEA DX, stg
INT 21H
a3: INT 03H
END
INPUT:
OUTPUT:
RESULT:
Date: Exp. No – 7
Logical Operations
(A) Shift Logical Right
AIM: To perform the shift right operation.
APPARATUS: System with TASM Software
ALGORITHM:
1. Assign model to the program.
2. Assign Code segment.
3. Move the data to be shifted into AL register.
3. Specify the number of shift operations to be performed in CL register.
4. Perform shift right operation and observe the result in AL register.
5. Terminate the program by using break point interrupt.
6. End
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 46H
MOV CL, 04H
SHR AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 46H
MOV CL, 04H
SHL AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 68H
MOV CL, 04H
ROR AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 60H
MOV CL, 04H
ROL AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 68H
MOV CL, 04H
RCR AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV AL, 68h
MOV CL, 04h
RCL AL, CL
INT 03H
END
INPUT:
OUTPUT:
RESULT:
RESULT:
PROGRAM:
. MODEL SMALL
. CODE
MOV BL, 57H
MOV CL, 04H
MOV AL, BL
SHL AL, CL
ROR AL, CL
MOV DL, AL
MOV AL, BL
SHR AL, CL
MOV DH, AL
XOR DX, 3030h
INT 03H
END
INPUT: BL=57H
OUTPUT: DX=3537H
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
STRING DB ‟SVCET‟,‟$‟
STRING1 DB 05H DUP (?),‟$‟
COUNT DB 05H
. CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CL, COUNT
MOV SI, OFFSET STRING
MOV DI, OFFSET STRING1
CLD
REP MOVSB
MOV AH, 09H
LEA DX, STRING1
INT 21H
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
.MODEL SMALL
.DATA
STG DB „SVCET‟,‟$‟
STG1 DB 05H DUP (?), „$,
COUNT DB 05H
.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CL, COUNT
MOV SI, OFFSET STG
MOV DI, OFFSET STG1
CLD
ADD SI, 04h
A1: MOVSB
DEC SI
DEC SI
DEC CL
JNZ A1
MOV AH, 09H
LEA DX, STG1
INT 21H
INT 03H
END
INPUT:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
STRG1 DB „SVCET‟,‟$‟
STRG2 DB „SVPET‟, $‟
RES DB „STRGS ARE EQUAL‟,‟$‟
RES1 DB „STRGS ARE NOT EQUAL‟,‟$‟
COUNT EQU 03H
. CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CL, COUNT
LEA SI, STRG1
LEA DI, STRG2
CLD
REPE CMPSB
JNZ A2
MOV AH, 09H
LEA DX, RES
INT 21H
JMP A1
A2: MOV AH, 09H
LEA DX, RES1
INT 21H
A1: INT 03H
END
INPUT1:
INPUT2:
OUTPUT:
RESULT:
PROGRAM:
. MODEL SMALL
. DATA
S1 LABEL BYTE
LX1 DB 30H
A2 DB?
. CODE
MOV AX, @DATA
MOV DS, AX
MOV AH, 0AH
LEA DX, S1
INT 21H
MOV AH, 02H
MOV DL, A2
OR DL, 30H
INT 21H
END
INPUT:
OUTPUT:
RESULT:
PART-B
(Minimum 02 experiments to be conducted)
Memory Op-
Label Mnemonics operands Comments
Address Code
0400 B0 MOV AL,80H
0401 80
0402 E6 OUT 76H,AL
0403 76
0404 B0 START MOV AL,00H
0405 00
0406 E6 BACK OUT 70H,AL
0407 70
0408 FE INC AL
0409 C0
040A 3C CMP AL,FFH
040B FF
040C 76 JBE BACK (0406)
040D F8
040E EB JMP START (0404)
040F F4
RESULT:
Memory Op-
Label Mnemonics Operands Comments
Address Code
0400 B0 MOV AL,80H
0401 80
0402 E6 OUT 76H,AL
0403 76
0404 B0 START MOV AL,00H
0405 00
0406 E6 BACK1 OUT 70H,AL
0407 70
0408 FE INC AL
0409 C0
040A 3C CMP AL,FFH
040B FF
040C 72 JB BACK (0406)
040D F8
040E E6 BACK2 OUT 70H,AL
040F 70
0410 FE DEC AL
0411 C8
0412 3C CMP AL,00H
0413 00
0414 77 JA BACK2
(040E)
0415 F8
0416 EB JMP BACK1
(0406)
0417 EE
RESULT:
(C) ALP (8086) for generating stair case wave form using DAC
PROGRAM:
ORG 0400H
MOV AL, 80H
OUT 76H, AL
MOV AL, 00H
(0406) BACK1: OUT 70H, AL
CALL DELAY (041E)
ADD AL, 33H
CMP AL, FFH
JB BACK1 (0406)
(0411) BACK2: OUT 70H, AL
CALL DELAY (041E)
SUB AL, 33H
CMP AL, 00H
JA BACK2 (0411)
JMP BACK1 (0406)
(041E) DELAY: MOV BX, 0111H
(0421) BACK3: DEC BX
JNZ BACK3 (0421)
RET
RESULT:
Date: Exp. No – 2
ALP (8086) for traffic light controller
AIM: To write an ALP for four road cross junction to control the traffic automatically.
GN
YN
GW YW RW RN
RS RE YE GE
YS
GS
RESULT:
Date: Exp. No – 3
ALP (8086) for stepper motor control
AIM: To write an ALP to run the stepper motor in anti-clockwise direction continuously.
APPARATUS: 1. 8086 Microprocessor kit.
2. Stepper Motor control board.
ALGORITHM:
1. Initialize the 8255 control port with 80h.
2. Copy 0Ah into AL register and send to port A then call delay program.
3. Copy 06h into AL register and send to port A then call delay program.
4. Copy 05h into AL register and send to port A then call delay program.
5. Copy 09h into AL register and send to port A then call delay program.
7. Repeat from step3 to step8 for stepper motor to rotate anti-clockwise direction continuously.
Port A Address: 70H
Port B Address: 72H
Port C Address: 74H
Control Port Address: 76H
Control Word Format of 8255
Consider PA4 to PA7 as 0
A1
A4 A2
A3
PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 Data output to Port A to run the stepper motor
0 0 0 0 A1 A3 A2 A4 in anti-clock wise direction
0 0 0 0 1 0 1 0 0AH
0 0 0 0 0 1 1 0 06H
0 0 0 0 0 1 0 1 05H
0 0 0 0 1 0 0 1 09H
PROGRAM:
0400: MOV AL, 80H
OUT 76, AL
0404: MOV AL, 0AH
OUT 70, AL
CALL 0423H
MOV AL, 06H
OUT 70, AL
CALL 0423H
MOV AL, 05H
OUT 70, AL
CALL 0423H
MOV AL, 09H
OUT 70, AL
CALL 0423H
JMP 0404H
0423: MOV CX, 0A0AH
0426: DEC CX
JNZ 0426
RET
RESULT:
PART-C
(Minimum 03 Experiments to be conducted)
8051 Microcontroller:
Date: Exp. No – 01
a) ALP (8051) to determine the addition of N bytes
AIM: To write an ALP for 8051 to determine the addition of N bytes
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Access the memory location 4000h through DPTR.
2. Copy the number of bytes to be added into R0 register.
3. Move the number zero into R1 register
4. Copy the content of DPTR into A Register.
5. Add the content of A register and R1 register with carry and result is stored in R1 register
6. Increment DPTR content
7. Decrement the register R0 by one if not zero control transfer to step 4
8. Access the memory location 4200h through DPTR
9. Store the result from A register into memory location 4200
9. Terminate the program by using LCALL 0003
PROGRAM:
3000: MOV DPTR, #4000
MOV R0, #05
MOV R1,#00
ADDRESS: MOV X A, @DPTR
ADDC R1, A
INC DPTR
DJNZ R0, ADDRESS
MOV DPTR, #4200
MOVX @DPTR, A
LCALL 0003
INPUT: 4000:01
4001:02
4002:03
4003:04
4004:01
OUTPUT: 4200:0B
Date: Exp. No – 01
b) ALP (8051) to determine the addition of N bytes
AIM: To write an ALP for 8051 to determine the subtraction of N bytes
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Access the memory location 4000h through DPTR.
2. Copy the number of bytes to be added into R0 register.
3. Move the number zero into R1 register
4. Copy the content of DPTR into A Register.
5. Subtraction the content of A register and R1 register with borrow and result is stored in R1
Register.
6. Increment DPTR content
7. Decrement the register R0 by one if not zero control transfer to step 4
8. Access the memory location 4200h through DPTR
9. Store the result from A register into memory location 4200
9. Terminate the program by using LCALL 0003
PROGRAM:
3000: MOV DPTR, #4000
MOV R0, #05
MOV R1,#00
ADDRESS: MOV X A, @DPTR
SUBB R1, A
INC DPTR
DJNZ R0, ADDRESS
MOV DPTR, #4200
MOVX @DPTR, A
LCALL 0003
INPUT: 4000:01
4001:02
4002:03
4003:04
4004:01
OUTPUT: 4200:
Date: Exp. No – 02
A) ALP (8051) to determine the largest of N bytes
AIM: To write an ALP for 8051 to determine the largest of n-bytes.
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Access the memory location 4000h through DPTR and copy the content into A register.
2. Copy the number bytes in an array into R0 register.
3. Copy the content of A register into F0 Register.
4. Increment DPTR to access next memory location.
5. Decrement the count value in R0 and increment DPTR to copy the next byte into A register.
6. Compare the content of A and F0 register if not equal control transfer to new location.
7. Short jump to another location.
8. If carry is set then increment the DPTR. If not copy the content of A to F0 register.
9. Repeat from step 5 until R0 becomes zero.
10. Copy the largest value into A register from F0.
11. Copy the output memory location into DPTR 4200.
12. Copy the largest value from A to memory location.
13. Terminate the program by using LCALL 0003.
RESULT:
RESULT:
Date: Exp. No – 3
(A) ALP (8051) to multiply a 16-bit number by an 8-bit number
AIM: To write an ALP (8051) to multiply a 16-bit number by an 8-bit number.
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Start
2. Access the memory location 3500h through DPTR and copy the LSB of 16-bit number content
into A register.
3. Copy the least significant byte in multiplicand from A into register R2.
4. Increment DPTR to access next memory location and copy the MSB into R1 through A register.
5. Increment DPTR and copy the 8-bit multiplier in R3 through A register.
6. Initialize the DPTR to store the product of multiplication.
7. Copy the content in R2 to B and perform multiplication between A and B.
7. Store the LSB of product in 4000h and increment DPTR.
8. Copy the content in B to R4 temporarily and R1 into B and R3 into A.
9. Perform the multiplication between A and B then add content of A and R4.
10. Store the next byte of product in 4001 from A and increment DPTR.
11. Copy the content in B to A and perform the addition between 00h and A.
12. Store the last byte of the product in 4002h
13. Terminate the program
PROGRAM:
3000: MOV DPTR, #3500
MOVX A, @ DPTR
MOV R2, A
INC DPTR
MOVX A, @ DPTR
MOV R1, A
INC DPTR
MOVX A, @ DPTR
MOV R3, A
MOV DPTR, # 4000
MOV B, R2
MUL AB
MOVX @ DPTR, A
INC DPTR
MOV R4, B
MOV B, R1
MOV A, R3
MUL AB
ADD A, R4
MOVX @ DPTR, A
INC DPTR
MOV A, B
ADDC A, # 00
MOVX @ DPTR, A
LJMP 16A5
INPUT: 3500=03; 3501=00; 3502=02 (0003x02)
RESULT:
ALGORITHM:
1. Start
2. Access the memory location 3500h through DPTR and copy the 8-bit number into A register.
3. Copy the content A into internal memory location 45H temporarily.
4. Assume initial square root value is 00h and store it in R1 register.
5. Copy the content of R1 to A and A to B then perform the multiplication between A and B.
6. Compare content of A and internal memory location 45H, if equal content of R1 is a square root
Number and copy into 4000h location through A register.
7. If not equal increment R1 and repeat step6.
8. Terminate the program
9. Stop
PROGRAM:
3000: MOV DPTR, #3500
MOVX A, @ DPTR
MOV 45H, A
MOV R1, #00
3008: MOV A, R1
MOV B, A
MUL AB
CJNE A, 45, 3017
MOV DPTR, #4000
MOV A, R1
MOVX @DPTR, A
LJMP 16A5
3017: INC R1
SJMP 3008
INPUT: 3500=09
OUTPUT: 4000=03
RESULT:
Date: Exp. No – 4
(A) ALP (8051) to determine LCM of two 8- bit number
AIM: To write an ALP (8051) to determine LCM of two 8- bit number.
APPARATUS: 8051 Microcontroller kit.
\ALGORITHM:
1. Start
2. Access the memory location 3500h through DPTR & copy the one 8-bit number into A register.
3. Copy the content of A intoR1 and increment DPTR.
4. Copy the content of DPTR memory location 3501h into R2 through A register.
5. Copy the content of R1 to internal memory location 10h and R2 into 20h.
6. Copy data in 10h location to A and compare with data in 20h, if equal content in A is the LCM
and move to 4000h location .
7. If not equal, clear the carry flag and subtract the data in 20h location from A then verify the
carry flag.
8. If carry not generated , copy the data in 20h to A and add the content of A and R2 then store the
result in 10h from A and perform step6.
9. If carry generated, copy the data in 10h to A and add the content of A and R1 then store the
result in 10h location from A and perform step6.
10. Terminate the program
11. Stop
PROGRAM:
ORG 3000
MOV DPTR, #3500
MOVX A,@DPTR
MOV R1, A
INC DPTR
MOVX A, @DPTR
MOV R2, A
MOV 10, R1
MOV 20, R2
(300C) BACK: MOV A, 10
CJNE A, 20, AHEAD (3013)
SJMP RESULT (3026)
(3013) AHEAD: CLR C
SUBB A, 20
JC FORWARD (301F)
MOV A, 20
ADD A, R2
MOV 20, A
SJMP BACK (300C)
(301F) FORWARD: MOV A, 10
ADD A, R1
MOV 10, A
SJMP BACK (300C)
(3026) RESULT: MOV DPTR, #3600
MOVX @DPTR, A
LJMP 16A5
INPUT1: 3500=02
INPUT2: 3501=04
OUTPUT: 3600=04
RESULT:
PROGRAM:
ORG 3000H
MOV DPTR, #3500H
MOVX A, @DPTR
MOV 10H, A
INC DPTR
MOVX A, @DPTR
MOV 20H, A
(300A) BACK: MOV A, 10H
CJNE A, 20H, AHEAD
SJMP RESULT (3023)
(3011) AHEAD: CLR C
SUBB A, 20H
JNC AHEAD1 (301F)
MOV A, 20H
CLR C
SUBB A, 10H
MOV 20H, A
SJMP BACK (300A)
(301F) AHEAD1: MOV 10H, A
SJMP BACK (300A)
(3023) RESULT: MOV DPTR, #3600
MOVX @DPTR, A
LJMP 16A5H
RESULT:
Date: Exp. No – 5
(A) ALP (8051) to generate even numbers
AIM: To write an ALP (8051) to generate even numbers.
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Start
2. Access the memory location 3500h through DPTR.
3. Copy zero value into R0 register.
4. Copy R0 content into A register.
5. Copy the Value of A register into external memory through DPTR.
6. Increment DPTR.
7. Increment the value of R0 twice.
8. Compare the value of R0 with 08 ;if not equal repeat from step 4.
9. Terminate the program by using LCALL 0003
PROGRAM:
3000: MOV DPTR, #3500
MOV R0, #00
BACK: MOV A, R0
MOVX @DPTR, A
INC DPTR
INC R0
INC R0
CJNE R0, #08, BACK
LCALL 0003
INPUT: R0=00
OUTPUT: 3500= 00; 3501=02; 3502= 04; 3502 =06
RESULT:
Date: Exp. No – 5
(B) ALP (8051) to generate odd numbers
PROGRAM:
3000: MOV DPTR, #3500
MOV R0, #01
BACK: MOV A, R0
MOVX @DPTR, A
INC DPTR
INC R0
INC R0
CJNE R0, #09, BACK
LCALL 0003
INPUT: R0=01
OUTPUT: 3500= 01; 3501=03; 3502= 05; 3502 =07
RESULT:
Date: Exp. No – 6
Timer/Counters in different modes
A) Timer in Mode -0 operation
AIM: To generate a square wave of frequency 1KHz at P1.0 of 8051 using timer 1 in mode 0..
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Program timer 1 in mode 0 by copy the value 00 into TMOD register
2. Clear both timer run bit as well as timer over flow bit.
3. Load 13-bit count value in timer 1 register i.e f1 into TH1 & 13 into TL1
4. Set the timer 1 run bit.
5. Check whether the timer 1 over flow is occurred or not .
6. Send to P1.0 and repeat from step 2
PROGRAM:
MOV TMOD, #00H; Program timer 1 in mode 0
4003: CLR TR1
CLR TF1
MOV TH1, #0F1H; load 13-bit count N in timer 1 register
MOV TL1, #13H
SETB TR1; run timer 1
400F: MOV C, TF1
JNC 400F
MOV C, P1.0
CPL C
MOV P1.0, C
SJMP 4003
RESULT:
Date: Exp. No – 6
Timer/Counters in different modes
Timer in Mode -1 operation
AIM: To generate a rectangular wave of frequency 1KHz with a duty cycle of 0.25 at P1.6 of 8051
using timer 0 in mode 1.
PROGRAM:
MOV TMOD, #01H; Program timer 0 in mode 1
NEXT: SETB P1.6
CLR TR0
CLR TF0
MOV TH0, #0FFH; load count N for timer 0 register
MOV TL0, #1AH
SETB TR0; run timer 0
BACK1: MOV C, TF0
JNC BACK1
CLR P1.6
CLR TR0
CLR TF0
MOV TH0,#0FDH; Count N2
MOV TL0,#4DH;for T2
SETB TR0
BACK2: MOV C, TF0
JNC BACK2
SJMP NEXT
RESULT:
Date: Exp. No – 6
Timer/Counters in different modes
B) Timer in Mode -2 operation
AIM: To generate a square wave of frequency 2KHz at P1.3 of 8051 using timer 1(TH0) in mode2.
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Program timer 1 in mode 2 by copy the value 20H into TMOD register
2. Clear timer run bit .
3. Load 8-bit count value in timer 1 register i.e 1A into TH1 & 1A into TL1
4. Clear timer 1 overflow bit and Set the timer 1 run bit.
5. Check whether the timer 1 over flow is occurred or not .
6. Send to P1.3 and repeat from step 4
PROGRAM:
MOV TMOD, #20H; Program timer 1 in mode 2
CLR TR1
MOV TH1,#1AH; load 8-bit count value in TH1
MOV TL1,#1AH; load 8-bit count value in TL1
BACK1: CLR TF1
SETB TR1
BACK2: MOV C, TF1
JNC BACK2
MOV C, P1.3
CPL C
MOV P1.3, C
SJMP BACK1
RESULT:
Date: Exp. No –6
Timer/Counters in different modes
Timer in Mode -3 operation
AIM: To generate a square wave of frequency 5KHz at P1.5 of 8051 using timer 0(TH0) in mode3.
APPARATUS: 8051 Microcontroller kit.
ALGORITHM:
1. Program timer 0 in mode 3 by copy the value 03H into TMOD register
2. Clear both timer 1 run bit and timer 1 over flow bit.
3. Load 8-bit count value in timer 0 register i.e A4 into TH0
4. Set the timer 1 run bit.
5. Check whether the timer 1 over flow is occurred or not.
6. Send to P1.5 and repeat from step 2
PROGRAM:
MOV TMOD, #03H; Program timer 0 in mode 3
BACK1: CLR TR1
CLR TF1
MOV TH0,#A4H; load 8-bit count value in TH0
SETB TR1
BACK2: MOV C, TF1
JNC BACK2
MOV C, P1.5
CPL C
MOV P1.5, C
SJMP BACK1
RESULT:
1. Open TASM folder and click on DPMIRES icon and type EDIT to open the editor window.
2. Type the assembly language program and save the program as FILENAME.ASM.
3. Go to file menu and click on exit to move to DOS prompt.
4. Type TASM FILENAME.ASM command to assemble the program.
5. If any errors in the program use EDIT FILENAME.ASM command.
5. Type TLINK FILENAME command to link the file to turbo assembler.
6. Type DEBUG FILENAME.EXE to place the exe file in memory.
7. Type „R‟ in the DOS prompt to see the register contents of 8086.
8. Type „T‟ in the DOS prompt to observe the register contents used in the program ,instruction by
instruction until end of the program.
9. Type „G‟ in the DOS prompt to run the entire program at a time.(if you use INT 03H in
program)
10. To observe the results available in memory locations type E 16-bit address after executing the
program.
VIVA QUESTIONS
1. What is meant by .model small?
2. How data segment is assigned in program.
3. How code segment is assigned in program.
4. How stack segment is assigned in program
5. What is the difference between EQU & DB directive.
6. Mention the precautions to take while assigning the data to the variables.
7. What is the function of @?
8. What is the significance of $ at end of the string.
9. Mention the command to link the source file to the assembler.
10. Mention the command to place the machine codes into memory.
11. What happened if any instructions are used after end directive?
12. Define Assembler directive
13. Mention the classification of assembler directives.
14. What is the size of the segments if model small is assign to the program?
15. When the stack segment has to assign in the program.
16. What is the advantage of memory segmentation?
17. What are the data define and storage allocation directives.
18. Mention the significance of start directive
19. What are the rules & regulations for assembler?
20. Which DOS command has to use to verify the data in memory location?
21. Which DOS command has to use to proceed to the interrupt?
22. Which DOS command is used to exit from DOS?
23. What is the difference between DOS & BIOS?
24. Which command is used to verify all the register contents of 8086?
25. What is the function of P command?
26. What is the significance of G command?
27. What is the difference between MUL & I MUL instructions?
28. What is the difference between TEST & AND instructions?
29. What is the significance of CX register in logical instructions?
30. What is the significance of CX register in loop instructions?