Upload
malk-malik
View
232
Download
1
Embed Size (px)
DESCRIPTION
2013 MPMC LAB MANNUEL
Citation preview
S.NoExperimentPage no
Programs for 16 bit arithmetic operations (using 8086)
Addition of two 16-bit numbers
Subtraction of two 16-bit numbers
Multiplication of two 16-bit numbers
Division of two 16-bit numbers
Double precision addition
Double precision subtraction
16 bit logical operations using 8086
Ones complement of a 16-bit numbers
Masking off bits selectively in 16-bit number
Setting off bits selectively in 16-bit number
Programs for string manipulation operations (using 8086)
Program for string primitive (using 8086)
String manipulation using 8086
Calculating the length of string
Code conversion
Programs for bcd number to binary number
Programs for binary number to bcd number
Programs for 8-bit binary number to gray code
Arithmetic operations using masm software
Programs for matrix addtion (3*3 matrix) using masm software
Programs for matrix multiplication (3*3 matrix) using masm software
String manipulation
Descending order of an array
Ascending order of an array
Largest number in an array
Smallest number in an array
Search a number in an array
Counters and delay program
Program for setting system date
Traffic light controller using 8086
Interfacing and programming of stepper motor
To run stepper motor at different speeds
To run stepper motor in both directions
Programs for digital clock and stop watch
Clock display
Stop watch display
Interfacing and programming of 8279 using 8086
Read a key
Rolling display (display message is cse- a)
Interfacing and programming of printer interface using 8086
Serial communication between two mp kits using 8251
Interfacing 8255 with 8086
Programs for interfacing ADC and DAC
Analog to digital converter
Digital to analog converter
Generation of saw tooth wave
Generation of square wave
Generation of triangular wave
Programming of 8051 microcontroller
Programming using arithmetic, logical and bit manipulation
Addition of two 8-bit numbers using 8051
Subtraction of two 8-bit numbers using 8051
Multiplication of two 8-bit numbers using 8051
Division of two 8-bit numbers using 8051
Ones and twos complement using 8051
Setting bits in an 8 bit numbers using 8051
Masking bits in an 8 bit numbers using 8051
Programs for sorting and searching (using 8051)
Arrange the given number in ascending order
Arrange the given number in descending order
Largest element in an array
Programming using arithmetic, logical and bit manipulation
Unmasked bcd number to ascii code using 8051
Square of a 8-bit number using 8051
Cube of a 8-bit number using 8051
EXPT NO: 16 BIT ARITHMETIC OPERATIONS DATE: (USING 8086)
AIM:To write an Assembly Language Program (ALP) for 16 bit Arithmetic operations using 8086.
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
ALGORITHM:
(i)16-bit addition:a) Start the program. b) Load the augend to the accumulator. c) Load the addend to any other general purpose register. d) Add these two register contents. e) Store the result in required memory location. f) Stop the program.
(ii) 16-bit subtraction:a) Start the program.b) Load the minuend to the accumulator.c) Load the subtrahend to any other general purpose register.d) Subtract these two register contents.e) Store the result in required memory locations.f) Stop the program.
(iii)Multiplication of 16-bit numbers:a) Start the program.b) Load the multiplicand to the accumulator.c) Load the multiplier to any other general purpose register.d) Add the multiplicand, multiplier times.e) Store the result in required memory location.f) Stop the program.(iv)Division of 16-bit numbers:a) Start the program.b) Load the dividend to the accumulator.c) Load the divisor to any other general purpose register.d) Subtract the dividend, divisor times.e) Store the result in required memory location.f) Stop the program.(v)Double precision Addition: a) Start the program. b) Load the 16 bit augend to the accumulator. c) Load the 16 bit addend to any other general purpose register. d) Add these two register contents with carry. e) Store the result in required memory location. f) Stop the program
(vi)Double precision subtraction:a) Start the program.b) Load the 16 bit minuend to the accumulator.c) Load the 16 bit subtrahend to any other general purpose register.d) Subtract these two register contents with borrow.e) Store the result in required memory locations.f) Stop the program.
. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
A-ADDITION OF TWO 16-BIT NUMBERS
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX,[1100]A1,00,11MOVE THE DATA TOACCUMULATOR
1003ADD AX,[1102]03,06,02,11ADD MEMORYCONTENTWITH ACCUMULATOR
1007MOV [1200],AXA3,00,12MOVEACCUMULATORCONTENT TOMEMORY
100AHLTF4STOP
OUT PUT:
IN PUTADDRESSDATA
OUT PUTDATA
ADDRESS
1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
B-SUBTRACTION OF TWO 16-BIT NUMBERS
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX[1100]A1,00,11MOVE THE DATA TO
ACCUMULATOR
1003SUB AX[1102]2B,06,02,11SUBTRACT
MEMORY CONTENT
WITH
ACCUMULATOR
1007MOV [1200],AXA3,00,12MOVE
ACCUMULATOR
CONTENT TO
MEMORY
100AHLTF4STOP
OUT PUT:
IN PUTDATA
OUT PUTDATA
ADDRESS
ADDRESS
1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
C-MULTIPLICATION OF TWO 16-BIT NUMBERS
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX[1100]A1,00,11MOVE THE DATA TO
ACCUMULATOR
1003MUL[1102]F7,26,02,11MULTIPLY MEMORY
CONTENT
WITH
ACCUMULATOR
1007MOV [1200],DX87,16,00,12MOVE
ACCUMULATOR
CONTENT TO AX
REGISTER
100BMOV[1202],AXA3,02,12MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER
100EHLTF4STOP
OUT PUT:
IN PUTDATA
OUT PUTDATA
ADDRESS
ADDRESS
1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
D-DIVISION OF TWO 16-BIT NUMBERS
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX[1100]A1,00,11MOVE THE DATA
TO
ACCUMULATOR
1003DIV[1102]
F7,36,02,11DIVIDE MEMORY
CONTENT
WITH
ACCUMULATOR
1007MOV [1200],DX87,16,00,12MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER
100B
MOV[1200],AXA3,00,12MOVE CONTENT
OF AX
REGISTER TO
MEMORY
100EHLTF4STOP
OUT PUT:
IN PUTDATA
OUT PUTDATA
ADDRESS
ADDRESS
1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
E-DOUBLE PRECISION ADDITION
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX,[1100]A1,00,11MOVE THE DATATOACCUMULATOR
1003ADD AX,[1104]03,06,04,11ADD MEMORYCONTENT WITH ACCUMULATOR
1007MOV [1200],AXA3,00,12MOVE DATA INMEMORYTO ACCUMULATOR
100AMOV AX,[1102]A1,02,11MOVEACCUMULATOR VALUE TO MEMORY
100DADC AX,[1106]13,06,06,11ADD ACCUMULATOR VALUE WITH CARRY
1011MOV[1202],AHA3,02,12MOVE ACCUMULATOR VALUE TO MEMORY
1014LAHF9FMOVE HIGHER VALUE TO MEMORY
1015MOV[1204],AH88,2,04,12MOVE ACCUMULATOR VALUE TO MEMORY
1019HLTF4STOP
OUT PUT:
IN PUTDATA
OUT PUTDATA
ADDRESS
ADDRESS
1. PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
F-DOUBLE PRECISION SUBTRACTION
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX,[1100]A1,00,11 MOVE THE DATA TO
ACCUMULATOR
1003SUB AX,[1104]2B,06,04,11SUBTRACT
MEMORY
CONTENT WITH
WITH
ACCUMULATOR
1007MOV [1200],AXA3,00,12MOVE DATA IN
MEMORY TO
ACCUMULATOR
100AMOV AX,[1102]A1,02,11MOVE
ACCUMULATOR
VALUE TO MEMORY
100DSBB AX,[1106]2B,06,06,11SUBTRACT MEMORY
CONTENT WITH
ACCUMULATOR
1011MOV[1202],AXA3,02,12MOVE ACCUMULATOR
VALUE TO MEMORY
1014HLTF4STOP
OUT PUT:
IN PUTDATA
OUT PUTDATA
ADDRESS
ADDRESS
Result:
Thus, the programs for Arithmetic operations have been executed using 8086 MicroprocessorEXPT NO: 16 BIT LOGICAL OPERATIONSDATE: (USING 8086)
AIM:To write an Assembly Language Program (ALP) for 16 bit logical operations using 8086
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
ALGORITHM:
(i) ONES COMPLEMENT OF A 16 BIT NUMBERS:a) Start the program.b) Load the input data to the Accumulator.c) Perform negation on Accumulator.d) Store the result in required memory location.e) Stop the program.
(ii) MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER:a) Start the program.b) Load the first input data to the Accumulator.c) Perform AND operation with AX and second datad) Store the result in required memory location.e) Stop the program.(iii) SETTING OF BITS SELECTIVELY:a) Start the program.b) Load the first input data to the Accumulator.c) Perform OR operation with AX and second datad) Store the result in required memory location.e) Stop the program.
PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)
A-ONES COMPLEMENT OF A 16-BIT NUMBERS
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX 1234B8,34,12MOVE THE DATA
TO
ACCUMULATOR
1003NOT AXF7,D0NOT OPERATION
WITH
ACCUMULATOR
1007MOV [1400],AXA3,00,14MOVE DATA IN
MEMORY
TO
ACCUMULATOR
1009HLTF4STOP
OUT PUT:
IN PUT:
DATA:OUT PUTDATA
ADDRESS
2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)
B-MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX, [1200]A1,00,12MOVE THE DATA
TO
ACCUMULATOR
1003AND AX, 0F0F25,0F,0FAND OPERATION
WITH
ACCUMULATOR
1007MOV [1400],AXA3,00,14MOVE DATA IN
MEMORY
TO
ACCUMULATOR
1009HLTF4STOP
OUT PUT:
IN PUT:
IN PUTDATAOUT PUTDATA
ADDRESSADDRESS
2. PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)
C- SETTING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AX ,0000B8,00,00CLEAR
ACCUMULATOR
1003OR AX, 0F0F0D,0F,0FOR OPERATION
WITH
ACCUMULATOR
1007MOV [1400],AXA3,00,14MOVE DATA IN
MEMORY
TO
ACCUMULATOR
1009HLTF4STOP
OUT PUT:
IN PUT:
IN PUTDATAOUT PUTDATA
ADDRESSADDRESS
Result:
Thus, the programs for Logical operations have been executed using
8086 MicroprocessorEXPT NO: SORTING AND SEARCHING DATE: (USING 8086)AIM:To write an Assembly Language Program (ALP) for sorting and searching operations using 8086. APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
ALGORITHM:
(i) PROGRAM FOR STRING PRIMITIVE:a) Start the program.b) Get the number of count to be made.c) Load the output address in the destination index.d) Load the input value to the accumulator.e) Store the result in required memory locations using STO.f) Stop the program.(ii) STRING MANIPULATION:a) Start the program.b) Load the input address in the source index.c) Load the output address in the destination index.d) Get the number of count to be made.e) Store the result in required memory location.f) Stop the program.(iii) CALCULATING THE LENGTH OF THE STRING:a) Start the program.b) Load the input address to the source index.c) Load the data to any other general purpose register.d) Load the data to accumulator.e) Compare the accumulator higher and lower bit.f) Store the result in required memory location.g) Stop the program.
3. PROGRAMS FOR STRING MANIPULATION OPERATIONS (USING 8086)
A-PROGRAM FOR STRING PRIMITIVE (USING 8086)
ADDRESSLOOPMNEMONICSOPCODECOMMENTS
1000MOV CX, 0010B9 10 00Count the value of
array
1003MOV DI,[1100]BF 00 11Declare destination
index
1006MOV AX, 0034B8 34 00Move the data to
accumulator
1009CLDFCClear direction
100AL1STO SBAAStore byte till
assigned address
100BLOOP L1E2 FDMove to loop L1
100DHLTF4Stop
3. PROGRAMS FOR SORTING AND SEARCHING (USING 8086)
B-STRING MANIPULATION USING 8086
ADDRESSLABELMNEMONICSOP-CODECOMMAND
1000MOV SI [1100]BE 00 11MOVE ADDRESS
OFFSETTO SOURCE
S_ARRAYINDEX
1003MOV DI [1200]BF 00 12MOVE ADDRESS
OFFSETTO DESTINATION
D_ARRAYINDEX
1006MOV CX 0005B9 05 00DECLARE THE
SIZE OF ARRAY
ELEMENT
1009CLDFCCLEAR
DIRECTION
100AL1MOVE SBA4MOVE DATA
100BLOOP L1E2 FDMOVE TO LOOP
L1
100DHLTF4STOP THE
PROGRAM
OUT PUT:
IN PUT:
IN PUTDATAOUT PUTDATA
ADDRESSADDRESS
3. PROGRAMS FOR SORTING AND SEARCHING (USING 8086)
C-CALCULATING THE LENGTH OF STRING
ADDRESSLABELMNEMONICSOP-CODECOMMAND
1000MOV SI [1100]BE 00 11MOVE ADDRESS
TO SOURCE
INDEX
1003MOV DXBA FF FFMOVE DATA TO
FFFFREGISTER
1006MOV AH FFB4 FFMOVE DATA TO
ACCUMULATOR
HIGHER BIT
1008L1INC DX42INCREMENT ON
DX
1009MOV [AL] SI8A 04MOVE SOURCE
INDEX TO ACC.
LOWER
100BINC SI48INCREMENT ON
SI
100CCMP AH AL38 C4COMPARE ACC.
HIGHER AND
LOWER
100EJNZ L175 F8JUMP NO ZERO
MOVE TO L1
1010MOV [1200]89 16 00 12MOVE
DXREGISTER TO
1200
1014HLTF4STOP THE
PROGRAM
OUT PUT:
IN PUT:
IN PUTDATAOUT PUTDATA
ADDRESSADDRESS
Result:
Thus, the programs for Sorting and searching operations have been executed using 8086 Microprocessor4. EXPT NO: CODE CONVERSION DATE: (USING 8086)PROGRAMS FOR BCD NUMBER TO BINARY NUMBER
AIM:To write an assembly language program (alp) for BCD number to binary number using 8086. APPARATUS REQUIRED:SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAM
ASSUME CS: CODE, DS: DATADATA SEGMENTBCD_NUM EQU 4576HBIN_NUM DW (?)DATA ENDSCODE SEGMENTSTART: MOV AX,DATAMOV DS,AXMOV BX, BCD_NUMMOV CX,0CONT: CMP BX,0JZ EPRGMOV AL,BLSUB AL,01DASMOV AL,BHSBB AL,00DASMOV BH,ALINC CXJMP CONTEPRG: MOV BIN_NUM,CXMOV AH.4CHINT 21HCODE ENDSEND START
Result:
Thus, the programs for BCD NUMBER TO BINARY NUMBERhave been executed using 8086 Microprocessor
PROGRAMS FOR BINARY NUMBER TO BCD NUMBERAIM:To write an assembly language program (alp) for binary number to BCD number using 8086. APPARATUS REQUIRED:SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAM
ASSUME CS: CODE, DS: DATADATA SEGMENTBIN EQU 4576HRES DW (?)DATA ENDSCODE SEGMENTSTART: MOV AX,DATAMOV DS,AXMOV BX, BINMOV AX,0MOV CX,0CONT: CMP BX,0JZ EPRGDEC BXMOV AL,CLADD AL,01DAAMOV CL,ALMOV AL,CHADC AL,00DAAMOV CH,ALJMP CONTEPRG: MOV RES,CXMOV AH.4CHINT 21HCODE ENDSEND START
Result:
Thus, the programs for BINARY NUMBER TO BCD NUMBER have been executed using 8086 Microprocessor
PROGRAMS FOR 8-BIT BINARY NUMBER TO GRAY CODEAIM:To write an assembly language program (ALP) for binary number to gray code using 8086. APPARATUS REQUIRED:SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAMASSUME CS: CODE, DS: DATADATA SEGMENTNUM EQU 45HRES DB (?)DATA ENDSCODE SEGMENTSTART: MOV AX,DATAMOV DS,AXMOV AL, NUMMOV BL,ALCLCRCR AL,1XOR BL,ALMOV RES,BLMOV AH.4CHINT 21HCODE ENDSEND START
Result:
Thus, the programs for BCD NUMBER TO ASCII NUMBER have been executed using 8086 Microprocessor
ARITHMETIC OPERATIONS USING MASM SOFTWARE AIM: To perform arithmetic operations such as addition,subtraction, multiplication division operations using MASM software.
SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
ALGORITHM:
1. Initialize the data segment and the message to be displayed.2. Set function value for display.3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM: ASSUME CS:CODE,DS:DATADATA SEGMENT0PR1 EQU 98H0PR2 EQU 49HSUM DW 01 DUP(00)SUBT DW 01 DUP(00)PROD DW 01 DUP(00)DWS DW 01 DUP(00)DATA ENDSCODE SEGMENTSTART:MOV AX,DATAMOV DS,AXMOV BL,0PR2XOR AL,ALMOV AL,0PR1ADD AL,BLDAAMOV BYTE PTR SUM,ALJNC MSB0INC [SUM+1]MSB0:XOR AL,ALMOV AL,0PR1SUB AL,BLDASMOV BYTE PTR SUBT,ALJNB MSB1INC [SUBT+1]MSB1:XOR AL,ALMOV AL,0PR1MUL BLMOV WORD PTR PROD,AXXOR AH,AHMOV AL,0PR1DIV BLMOV WORD PTR DWS,AXMOV AH,4CHINT 21HCODE ENDSEND START
Result:
Thus, the programs for decimal arithmetic operations have been executed using MASM
PROGRAMS FOR MATRIX ADDTION (3*3 MATRIX) USING MASM SOFTWARE AIM: To perform matrix addition (3*3 matrix) using MASM software.
SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAM
ASSUME CS: CODE, DS: DATADATA SEGMENTDIM EQU 09HMAT1 DB 01, 01, 01, 01, 01, 01, 01, 01, 01MAT2 DB 01, 01, 01, 01, 01, 01, 01, 01, 01MAT3 DW 09H DUP (?)DATA ENDSCODE SEGMENTSTART: MOV AX,DATAMOV DS,AXMOV CX,DIMMOV SI,OFFSET MAT1MOV DI,OFFSET MAT2MOV BX, OFFSET MAT3NEXT: XOR AX,AXMOV AL,[SI]ADD AL,[DI]MOV WORD PTR [BX],AXINC SIINC DIADD BX,02LOOP NEXTMOV AH.4CHINT 21HCODE ENDSEND START
Result:
Thus, the programs for matrix addition have been executed using MASM
PROGRAMS FOR MATRIX MULTIPLICATION (3*3 MATRIX) USING MASM SOFTWARE
AIM: To perform matrix addition (3*3 matrix) using MASM software.
SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAM
ASSUME CS: CODE, DS: DATADATA SEGMENTROCOL EQU 03HMAT1 DB 01, 01, 01, 01, 01, 01, 01, 01, 01MAT2 DB 01, 01, 01, 01, 01, 01, 01, 01, 01MAT3 DW 09H DUP (?)DATA ENDSCODE SEGMENTSTART: MOV AX,DATAMOV DS,AXMOV CH,ROCOLMOV SI,OFFSET MAT1MOV BX, OFFSET MAT3NEXTROW: MOV DI,OFFSET MAT2MOV CL,ROCOLNEXTCOL: MOV DL,ROCOLMOV BP,0000HMOV AX,0000HSAHFNEXT_ELE:MOV AL,[SI]MUL BYTE PTR [DI]ADD BP,AXINC SIADD DI,03DEC DLJNZ NEXT_ELESUB DI,08SUB SI,03MOV [BX],BPADD BX,02DEC CLJNZ NEXTCOLADD SI, 03DEC CHJNZ NEXTROWMOV AH.4CHINT 21HCODE ENDSEND START
RESULT:
Thus, the programs for matrix addition have been executed using MASM
EXPT NO: STRING MANIPULATION DATE: (USING 8086)AIM:To write an Assembly Language Program (ALP) for string manipulation operations using 8086. APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
ALGORITHM:(i) DESCENDING ORDER OF AN ARRAY:a) Start the program.b) Store the total number of elements in c register.c) Store the data in accumulator.d) Compare the first element with the second element, which is placed after two bytes.e) If second elements are lesser, continue comparison with next data else exchange both the elements.f) Decrement the count value.g) Continue until count value becomes zero.h) Store the contents in memory location.i) Stop the program.
(ii) ASCENDING ORDER OF AN ARRAY:a) Start the program.b) Get the numbers to be stored from the memory locations.c) Compare the first two numbers and if the first number is larger than second then interchange the number.d) If the first number is smaller, go to step d.e) Repeat steps b and c until the numbers are in required order. f) Stop the program.
(iii) LARGEST NUMBER IN AN ARRAY:a) Start the program.b) Place all the elements of an array in the consecutive memory locations.c) Fetch the first element from the memory location and load it in the accumulator.d) Initialize a counter (register) with the total number of elements in an array.e) Decrement the counter by 1.f) Increment the memory pointer to point to the next element.g) Compare the accumulator content with the memory content (next element).h) If the accumulator content is larger, then move the memory content (largest element) to the accumulator. Else continue.i) Decrement the counter by 1.j) Repeat steps e to h until the counter reaches zero.k) Store the result (accumulator content) in the specified memory location.l) Stop the program.
(iv) SMALLEST NUMBER IN AN ARRAY:a) Start the program.b) Place all the elements of an array in the consecutive memory locations.c) Fetch the first element from the memory location and load it in the accumulator.d) Initialize a counter (register) with the total number of elements in an array.e) Decrement the counter by 1.f) Increment the memory pointer to point to the next element.g) Compare the accumulator content with the memory content (next element).h) If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue.i) Decrement the counter by 1.j) Repeat steps e to h until the counter reaches zero.k) Store the result (accumulator content) in the specified memory location.l) Stop the program.
(v) SEARCH A NUMBER IN AN ARRAY:a) Start the program.b) Load the input address in the source index.c) Load the output address in the destination index.d) Store the count value.e) Increment source index.f) Load the source index to the accumulator.g) Increment source index.h) Compare the present value stored in the accumulator and next value stored in the source index.i) If zero, then end else repeat from step e to g.j) Store the result in the specified memory location.k) Stop the program.
PROGRAM:DESCENDING ORDER OF AN ARRAYADDRESSLABELMNEMONICSOP-CODECOMMAND
1000STARTMOV BL,00B3 00COUNT THE VALUE OF ARRAY
1002MOV SI,1200BE 00 12MOVE THE DATA TO SOURCE INDEX
1005MOV CL,[SI]8A 0CMOVE THE MEMORY CONTENT TO COUNT REGISTER
1007DEC CLFE C9DECREMENT COUNT REGISTER
1009INC SI46INCREMENT SOURCE INDEX
100AMOV AL,[SI]8A 04MOVE THE MEMORY CONTENT SOURCE INDEX TO ACCUMULATOR
100CINC SI46INCREMENT SOUREC INDEX
100DCMP AL,[SI]3A 04COMPARE THE MEMORY CONTENT OF SOURCE INDEX WITH ACCUMULATOR
100FJC LOOP L172 0AJUMP ON CARRY
1011MOV DL,[SI]8A 14MOVE THE MEMORY CONTENT OF SOURCE INDEX TO DATA REGISTER
1013MOV [SI],AL88 04MOVE THE CONTENT OF ACCUMULATOR TO ADDRESS OF SOURCE INDEX
1015DEC SI4EDECREMENT SOURCE INDEX
1016MOV [SI],DL88 14MOVE THE CONTENT OF DATA REGISTER TO ADDRESS OF SOURCE INDEX
1018INC SI46INCREMENT SOURCE INDEX
1019MOV BL,01B3 01MOVE THE DATA TO BASE REGISTER
101BL1DEC CLFE C9DECREMENT COUNT REGISTER
101DJNZ LOOP75 EBJUMP ON NO ZERO
101FDEC BLFE CBDECREMENT BASE REGISTER
1021JZ START74 DDJUMP ON ZERO
1023HLTF4STOP
ASCENDING ORDER OF AN ARRAYADDRESSLABELMNEMONICSOP-CODECOMMAND
1000STARTMOV BL,00B3 00COUNT THE VALUE OF ARRAY
1002MOV SI,1200BE 00 12MOVE THE DATA TO SOURCE INDEX
1005MOV CL,[SI]8A 0CMOVE THE MEMORY CONTENT TO COUNT REGISTER
1007DEC CLFE C9DECREMENT COUNT REGISTER
1009INC SI46INCREMENT SOURCE INDEX
100AMOV AL,[SI]8A 04MOVE THE MEMORY CONTENT SOURCE INDEX TO ACCUMULATOR
100CINC SI46INCREMENT SOUREC INDEX
100DCMP AL,[SI]3A 04COMPARE THE MEMORY CONTENT OF SOURCE INDEX WITH ACCUMULATOR
100FJNC LOOP L172 0AJUMP ON NO CARRY
1011MOV DL,[SI]8A 14MOVE THE MEMORY CONTENT OF SOURCE INDEX TO DATA REGISTER
1013MOV [SI],AL88 04MOVE THE CONTENT OF ACCUMULATOR TO ADDRESS OF SOURCE INDEX
1015DEC SI4EDECREMENT SOURCE INDEX
1016MOV [SI],DL88 14MOVE THE CONTENT OF DATA REGISTER TO ADDRESS OF SOURCE INDEX
1018INC SI46INCREMENT SOURCE INDEX
1019MOV BL,01B3 01MOVE THE DATA TO BASE REGISTER
101BL1DEC CLFE C9DECREMENT COUNT REGISTER
101DJNZ LOOP75 EBJUMP ON NO ZERO
101FDEC BLFE CBDECREMENT BASE REGISTER
1021JZ START74 DDJUMP ON ZERO
1023HLTF4STOP
LARGEST NUMBER IN AN ARRAYADDRESSLABEL MNEMONICSOP-CODECOMMANDS
1000MOV BX,0005BB 05 00COUNT THE VALUE OF ARRAY
1003DEC BX4BDECREMENT BX REGISTER
1004L1MOV CX,BX8B CBMOVE THE CONTENT OF BX TO CX REGISTER
1006MOV SI,1100BE 00 11MOVE THE DATA TO SI
1009L2MOV AL,[SI]8A 04MOVE THE MEMORY CONTENT OF SI TO AL
100BINC SI46
100CCMP AL,[SI]3A 04COMPARE AL AND MEMORY CONTENT OF SI
100EJNC L373 05JUMP NO CARRY TO LOOP L3
1010XCHG AL,[SI]86 04EXCHANGE AL WITH MEMORY CONTENT OF SI
1012MOV[SI-1],AL88 44 FFMOVE THE CONTENT OF AL TO SI
1015L3LOOP L2E2 F2MOVE TO LOOP L2
1017DEC BX4BDECREMENT BX REGISTER
1018JNZ L175 EAJUMP ON NO ZERO TO LOOP L1
101AMOV[1200],ALA2 00 12MOVE THE CONTENT OF AL TO OUTPUT MEMORY
101DHLTF4STOP THE PROGRAM
SMALLEST NUMBER IN AN ARRAYADDRESSLABEL MNEMONICSOP-CODECOMMANDS
1000MOV BX,0005BB 05 00COUNT THE VALUE OF ARRAY
1003DEC BX4BDECREMENT BX REGISTER
1004L1MOV CX,BX8B CBMOVE THE CONTENT OF BX TO CX REGISTER
1006MOV SI,1100BE 00 11MOVE THE DATA TO SI
1009L2MOV AL,[SI]8A 04MOVE THE MEMORY CONTENT OF SI TO AL
100BINC SI46
100CCMP AL,[SI]3A 04COMPARE AL AND MEMORY CONTENT OF SI
100EJC L373 05JUMP ON CARRY TO LOOP L3
1010XCHG AL,[SI]86 04EXCHANGE AL WITH MEMORY CONTENT OF SI
1012MOV[SI-1],AL88 44 FFMOVE THE CONTENT OF AL TO SI
1015L3LOOP L2E2 F2MOVE TO LOOP L2
1017DEC BX4BDECREMENT BX REGISTER
1018JNZ L175 EAJUMP ON NO ZERO TO LOOP L1
101AMOV[1200],ALA2 00 12MOVE THE CONTENT OF AL TO OUTPUT MEMORY
101DHLTF4STOP THE PROGRAM
SEARCH A NUMBER IN AN ARRAYADDRESSLABEL MNEMONICSOP-CODECOMMAND
1000MOV SI,1200BE 00 12MOVE THE DATA TO SI
1003MOV DI,1500BF 00 15MOVE THE DATA TO DI
1006MOV CL,[SI]8A 0CMOVE THE MEMORY CONTENTS OF SI TO CL
1008INC SI46INCREMENT SI
1009MOV AL,[SI]8A 04MOVE THE MEMORY CONTENTS OF SI TO AL
100BINC SI46INCREMENT SI
100CLOOPCMP AL,[SI]3A 04COMPARE THE MEMORY CONTENT OF SI WITH AL
100EJZ END74 09IF JUMP ON ZERO THEN END
1010INC SI46INCREMENT SI
1011DEC CLFE C9DECREMENT CL
1013JNZ LOOP75 F7JUMP ON NO ZERO
1015MOV AL,0FFHB0 FFMOVE THE DATA TO AL
1017MOV [SI],AL88 04MOVE THE CONTENT OF AL TO SI
1019ENDMOV BL,[SI] 8A 1CMOVE THE MEMORY CONTENT OF SI TO BL
101BMOV [DI],BL88 1DMOVE THE CONTENT OF BL TO DI
101DINT 02HCD 02IN
101FHLTF4STOP
Result:
Thus, the programs for sorting and searching have been executed using 8086 Microprocessor
EXPT NO: COUNTERS AND DELAY PROGRAMDATE: (USING 8086)AIM:To write an Assembly Language Program (ALP) for string manipulation operations using 8086. APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
Write a program for delay of 8.96 ms if frequency of mp is 10 M HzMov bx, 64hRepe:Mov cx,32hBack: Dec cxJnz backDec bxJnz repeResult:
Thus, the programs for delay program have been executed using 8086 Microprocessor
EXPT NO: SYSTEM DATE
DATE: (USING 8086)Program for Setting System Date
AIM:To write an assembly language program (alp) Setting System Date using MASM software. APPARATUS REQUIRED:SL.NOITEM
1.PC
2.Keyboard
3MASM SOFTWARE
PROGRAM.model small .stack 100 .data MES DB 10,13,ENTER THE DATE WITH FORMAT: DD: MM :YY $MES 1 DB 10,13,DATE :$BUFF DB 10DB 0DB 10 DUP(0)YY DB ?MM DB ?D DB ?.CODE START: MOV AX, @DATAMOV DX,AXCALL P_DATA MOV AH,4CH INT 21H P_DATE PROC NEARMOV AH, 09HLEA DX,MES INT 21HMOV AH, 09HLEA DX,MES1 INT 21HMOV AH, 0AHLEA DX,BUFF INT 21HMOV CL,4MOV DL,00HLEA SI,BUFFADD SI,2BACK; MOV AL,[SI]CMP AL,:JZ TERROL DL.CLSUB AL,30HADD DL,ALINC SI JMP BACKTER: MOV DH,DLAND DL,-F0HROR DL,CLMOV AL,10MUL DL AND DH,-0FHADD AL,DHMOV D,AL MOV DL,0INC SIBACK1: MOV AL,[SI] CMP AL,: JZ TER1 ROL DL,CLSUB AL,30HADD DL, AL INC SI JMP BACK1TER1: MOV DH,DL AND DL,0F0H ROR DL,CLMOV AL,10MUL DL AND DH,0FHADD AL,DHMOV MM,ALMOV DL,0INC SIBACK2 MOV AL,[SI]CMP AL,13JZ TER2 ROD DL,CLSUB AL,30HADD DL,ALINC SI JMP BACK2TER2:MOV DH,DLAND DL,PFPHROR DL,CLSUB AL,30HADD DL,ALINC SI JMP BACK2SKIP2: MOV AH,2BH MOV CL,YY MOV CH,00ADD CX,2000MOV DH,MMMOV DL,DINT 21HRETP_DATE ENDPEND
RESULT:
Thus, the programs for setting the system time have been executed using MASM
TRAFFIC LIGHT CONTROLLER USING 8086AIMTo write an assembly language program to interface traffic light controller with 8086 using 8255.APPARATUS REQUIRED8086 Microprocessor kit, Power chord, Traffic light interface board26 channel busALGORITHM1. Find the control word for 8255 and data corresponding to the given conditions and load this data in to the memory location.2. Get the number of conditions in the C-register.3. Move the control word to accumulator and place in 8255.4. Move the first data to accumulator and place in port-A.5. Move the next data to accumulator and place in port-B.6. Move the next data to accumulator and place in port-C.7. Call the delay routine.8. Decrement the C-register. If C=0 then go to next step else go to step 3.9. Go to step 1 and Stop
PROGRAM
MEMORY ADDRESSLABELMNEMONICSOP CODE
1000START:MOV BX,1100HBB 00 11
1003MOV CX,000CHB9 00 0C
1006MOV AL,[BX]8A 07
1008OUT CONTRL,ALE6 0F
100A INC BX43
100B NEXT:MOV AL,[BX]8A 07
100D OUT PORTA,ALE6 0C
100F INC BX43
1010MOV AL,[BX]8A 07
1012OUT PORTB,ALE6 OD
1014INC BX43
1017MOV AL,[BX]8A 07
1019OUT PORTC,ALE6 0E
101BCALL DELAYE8 07 00
101EINC BX43
1021LOOP NEXT:E2 ED
1023JMP STARTEB DF
1024 DELAY:PUSH CX51
1025MOV CX,0005HB9 00 05
1028REPEAT:MOV DX,0FFFFHBA FF FF
103BLOOP2:DEC DX4A
103CJNZ LOOP275 FD
103ELOOP REPEATE2 F8
103FPOP CX59
1040RET C3
INPUT DATA
110080, 84, 2E, 4C
110484, 9D, 90, 93
11072B, 10, 64, 27, 12
PORT A [ {D0 - D20}0 - OFF & 1 ON ]
D8D7D6D5D4D3D2D1
POSITION 11000010084H
POSITION 21000010084H
POSITION 31001001193H
POSITION 40110010064H
PORT B [ {DL1 - DL8}0 - GREEN & 1 RED ]
D20D19D18D17DL78DL56DL34DL12
POSITION 1001011102EH
POSITION 2100111019DH
POSITION 3001010112BH
POSITION 40010011127H
PORT C [ {D0 - D20}0 - OFF & 1 ON ]
D16D15D14D13D12D11D10D9
POSITION 1010011004CH
POSITION 21001000090H
POSITION 30001000010H
POSITION 40001001012H
RESULTThus the assembly language program to interface traffic light controller with 8086 using 8255 was written and executed successfully.
EXPT NO: INTERFACING AND PROGRAMMING OF STEPPER DATE: MOTORSTEPPER MOTOR INTERFACINGAIM:
To write an assembly language program to interface stepper motor with 8086.
APPARATUS REQUIRED:
SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3.Power chord1
4.Stepper motor1
5.Interface boardStepper motor1
6.50 Channel Bus
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the next. Stepper Motors are used very wisely in position control systems like printers, disk drives, process control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a permanent magnet with one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to run the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.
2-PHASE SWITCHING SCHEME
In this scheme, any two adjacent stator windings are energized. The switching scheme is shown in the table given below. This scheme produces more torque.
ANTICLOCKWISECLOCKWISE
STEAA2BB2DATASTEAABB2DATA
P11P121
110019h11010Ah
201015h201106h
301106h301015h
41010Ah410019h
ADDRESS DECODING LOGIC
The 74138 chip is used for generating the address decoding logic to generate the device select pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor driving circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry that generates the driving pulses uses silicon Darlington pair transistors. The inputs for the interface circuit are TTL pulses generated under software control using the Microcontroller Kit. The TTL levels of pulse sequence from the data bus are translated to high voltage output pulses using a buffer 7407 with open collector.
PROGRAM:TO RUN STEPPER MOTOR AT DIFFERENT SPEEDS
ADDRESSLABELMNEMONICSOPCODE
1000START: MOV BL,20HB3 20
1002FORWD: MOV DI,OFFSET FORWBF 37 10
1005CALL ROTATEE8 1800
1008DEC BLFE CB
100A JNZ FORWD75 F6
100C CALL DELAYE8 21 00
100FMOV BL,20H B3 20
1011REVER: MOV DI,OFFSET REVBF 3B 10
1014CALL ROTATEE8 09 00
1017DEC BLFE CB
1019JNZ REVER75 F6
101B CALL DELAYE8 12 00
101E JMP STARTEB E0
1020 ROTATE: MOV CL,04B1 04
1022REPT: MOV AL,[DI]8A 05
1024OUT PORT1,ALE6 C0
1026MOV DX,1010H BA 1010
1029LOOP1: DEC DX4A
102A JNZ LOOP175 FD
102C INC DI47
102DLOOP REPT E2 F3
102F RETC3
1030MOV DX,0FFFFHBA FFFF
1033DELAY: DEC DX4A
103475 FD JNZ DELAY
1036RETC3
1037FORW: 9,5,6,0AH 09 05 06 0A
103B REV:0AH,6,5,90A 06 05 09
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED
MEMORYLABELMNEMONICSOPCODE
ADDRESS
1000STARTMOV D1 offsetBF,14,10
table (1014)
1003MOV CL, 04B1,04
1005LOOP1MOV AL,[D1]8A,05
1007OUTE6,C0
PORT1,AL
1009MOV DX,1010BA,10,10
100CDELAYDEC DX4A
100DJNZ DELAY75,FD
100FINC D147
1010LOOP LOOP1E2,F3
1012JMP STARTEB,EC
1014TABLEDB09,05,06,0A
EXPT NO: PROGRAMS FOR DIGITAL CLOCK AND STOP WATCH DATE: (USING 8086)
AIM:To write an Assembly Language Program (ALP) to display the Computers real-time clock on the screen as in digital clock.
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Macro assemblersoftware1
2.PC1
THEORY:CLOCK DISPLAY:Every PC is equipped with a real-time clock operated by a small battery. Even when the computer is switched off, this clock continues to function to maintain the clock in its CMOS registers. When the PC is on, the Operating System software reads this clock and stores the value in memory. User programs can access this data. The OS software provides facilities for the programmer to read this clock value using Software Interrupts. The IBM PC system BIOS also provides interrupt services to access this real time clock. The BIOS services provide the hours, minutes and seconds in CPU registers as BCD data. Hence they can be converted easily into ASCII value for displaying on screen.STOP WATCH DISPLAY:Every PC is equipped with BIOS that contains software to initialize the built in Timer IC to produce ticks with a periodicity of 18.2 ticks per every second. This does not rely on the real-time clock usually incorporated in the PC. The BIOS maintains the number of ticks elapsed since midnight or power-on of the machine. BIOS Interrupt 1Ah service provides the number of ticks elapsed at any time. One can use this service repeatedly to check for completion of 18 ticks, which would mean an approximate 1-second time gap. This can be used to update a memory variable to count seconds. After 60 seconds counting, the minute variable can be updated. Thus a stopwatch can be made to operate at the press of a key.
ALGORITHM:1. CLOCK DISPLAY PROGRAM:a) Initialize data segment to hold the clock data as hours, minutes and seconds.b) Display a message on screen for the user.c) Call the procedure to get the time from PCs real-time clock using BIOS interrupt.d) Call the procedure to convert the clock data into ASCII and display it on the screen.e) Check for user key press using BIOS interrupt service.f) If no key is pressed continue updating the clock on screen.g) If a key is pressed terminate the program.Procedure Get Time:a) Use Function 02 in Interrupt 1Ah service to read the PCs real-time clock. This function returns hours in CH, minutes in CL and seconds in DH registers.b) Divide each of these registers by 10h to separate the BCD digits.c) Convert each separated digit into ASCII by adding 30h with it.d) Store each digit in the appropriate location in the memory.e) Return from the procedure.Procedure ShowTime:a) Use BIOS interrupt 10h function 02h to set video cursor at desired location on the screen.b) Use DOS interrupt 21h function 09h to display the stored clock data from Data segment memory as a string terminated by $.c) Call a procedure to delay for few milliseconds doing nothing.d) Return from the procedure.Procedure Delay:a) Load a value in CX register.b) Do nothing.c) Decrement CX register by one.d) Loop until CX register is zero.e) Return from the procedure.
2. STOP WATCH DISPLAY:a) Initialize Data Segment Registerb) Display a friendly message using DOS Int 21h function 09hc) Call the procedure to show the watch with zero valuesd) Check for user key press using BIOS Int 16h function 01he) If no key is pressed go to step 4f) On key press, call the procedure to start the watch.g) On return from the procedure terminate the programProcedure Show watch:a) Position the video cursor at the desired location on screen using BIOS Int 10h function 02hb) Display the watch data in memory using DOS Int 21h function 09hc) Return from the procedureProcedure Start Watch:a) Get the current tick value using BIOS Int 1Ah function 00hb) Store the last two digits of the returned value in DL into BL. This becomes the old valuec) Get the current tick value using BIOS Int 1Ah function 00hd) Subtract the old value from the new valuee) Check whether it is 18 (which means 1 second)f) If it is less than 18, goto step 3g) If it is equal to 18, then increment LSD of seconds.h) If LSD is greater than 9, proceed to increment MSD of seconds and make LSD of seconds equal to 0i) Upon incrementing MSD of seconds if it is equal to 6, then make MSD equal to 0 and proceed to update minutes.j) Increment LSD of minutes.k) If LSD of minutes is greater than 9, increment MSD of minutes and make LSD equal to 0l) If MSD of minutes is equal to 6, then make minutes and seconds equal to 0.m) Call the procedure to Show the Watch.n) Check for User key press using BIOS Int 16h function 01h.o) If there is no key press proceed to step 1p) If there is a key pressed, check whether that key is q.q) If the key pressed is q, then return from the procedure.r) Otherwise, go to step 1
PROGRAM:CLOCK DISPLAY PROGRAM
.MODEL SMALL.STACK.DATAMESSAGE DB 0AH,0DHMESSAGE1 DB 0AH,0DHPROMPT DB TIMER::HOURS1 DB 0HOURS2 DB 0SEPERATOR1 DB :MINUTES1 DB 0MINUTES2 DB 0SEPERATOR2 DB :SECONDS1 DB 0SECONDS2 DB 0LAST DB $DIVISOR DB 10H.CODEMOV AX,@DATAMOV DS,AXMOV AH,09HLEA DX,MESSAGEINT 21HAGAIN:CALL GETTIMECALL SHOWTIMEMOV AH,01HINT 16HJZ AGAINMOV AH,04CHINT 21HGET TIME PROCMOV AH,02HINT 1AHMOV AL,CHDIV DIVISORADD AL,30HADD AH,30HMOV HOURS1,ALMOV HOURS2,AHXOR AX,AXMOV AL,CLDIV DIVISORADD AL,30HADD AH,30HMOV MINUTES1,ALMOV MINUTES2,AHXOR AX,AXMOV AL,DHDIV DIVISORADD AL,30HADD AH,30HMOV SECONDS1,ALMOV SECONDS2,AHRETGET TIME ENDPSHOW TIME PROCMOV AH,02HMOV BH,0MOV DH,20DMOV DL,10DINT 10HMOV AH,09HLEA DX,PROMPTINT 21HCALL DELAY RETSHOW TIME ENDPDELAY PROCPUSH CXMOV CX,0FFFHIDLE:NOPNOPNOPNOPLOOP IDLE OUTPOP CXRETDELAY ENP ENDSTOP WATCH DISPLAY.MODEL SMALL.STACK.DATAMESSAGE DB 0AH,0DHMESSAGE1 DB 0AH,0DHPROMPT DB TIMER::MINUTES1 DB 0MINUTES2 DB 0SEPARATOR1 DB :SECONDS1 DB 0SECONDS2 DB 0SEPERATOR2 DB .LAST DB $DIVISOR DB 10H.CODEMOV AX,@DATAMOV DS,AXMOV AH,09HLEA DX,MESSAGEINT 21HCALL SHOW WATCHAGAIN: MOV AH,01HINT 16HJZ AGAINCALL START WATCHMOV AH,04CHINT 21HSTART WATCH PROCDOITAGAIN:MOV AH,00HINT 1AHMOV BL,DLCHECKAGAIN:MOV AH,00HINT 1AHSUB DL,BLCMP DL,18JB CHECKAGAINMOV AL,SECONDS2INC ALCMP AL,39HJBE UPDATE_SECONDS2MOV AL,30HMOV SECONDS2,ALMOV AL,SECONDS1INC ALCMP AL,36HJB UPDATE_SECONDS1MOV AL,30HMOV MINUTES2,ALMOV AL,MINUTES2INC ALCMP AL,39HJBE UPDATE_MINUTES2MOV AL,30HMOV MINUTES2,ALMOV AL,MINUTES1INC ALCMP AL,36HJB UPDATE_MINUTES1MOV AL,0UPDATE_MINUTES1:MOV MINUTES1,ALJMP DONEUPDATE_MINUTES2:MOV MINUTES2,ALJMP DONEUPDATE_SECONDS1:MOV SECONDS1,ALJMP DONEUPDATE_SECONDS2:MOV SECONDS2,ALDONE:CALL SHOW_ WATCHMOV AH,01HINT 16HJNZ CHECK_KEYJMP DOITAGAINCHECK_KEY:MOV AH,00HINT 16HCMP AL,qJNZ DOITAGAINRETSTART_WATCH ENDPSHOW_WATCH PROCMOV DH,10DMOV DL,10DMOV AH,02HMOV BH,0INT 10HMOV AH,09HLEA DX,PROMPTINT 21HRETSHOW_WATCH ENDPEND
EXPT NO: INTERFACING AND PROGRAMMING OF 8279 USING 8086DATE:
AIM:
To perform interfacing and programming using 8279, 8259 and 8253 using 8086.
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3.Power chord1
4.50 channel bus3
5.8279 kit1
ALGORITHM:ROLLING DIAPLAYa) Start the program.b) Set 8279 for 8-bit character display right entry and a key lock out.c) Clear the display.d) Load the data to control register to write to the display.e) Set the counter value.f) Initialize the HL register pair and memory pointer.g) Call the subroutine for delay procedure.h) Increment H and decrement B register.i) Repeat the steps e and hj) Stop the program.READ A KEY:ADDRESSLABELMNEMONICSOPCODE
1000MOV BX,1100 BB 00 11
1003LOOP: IN AL,C2 E4 C2
1005TEST AL,07 A8 07
1007JZ LOOP 74 FA
1009MOV AL,40 B0 40
100B OUT C2,AL E6 C2
100D IN AL,C0 E4 C0
100F MOV [BX],AL 88 07
1011HLT F4
ROLLING DISPLAY (DISPLAY MESSAGE IS CSE- A)
ADDRESSLOOPMNEMONICSOP-CODECOMMANDS
1000STARTMOV SI,1200BE 00 12SET MODE COUNT AND DISPLAY
1003MOV CX,000FB9 0F 00MOVE 000F DATA IN CX
1006MOV AL,10B0 10SET ACC DATA
1008OUT C2,ALE6 C2CLEAR DISPLAY
100AMOV AL,CCB0 CCMOVE CC DATA IN AL
100COUT C2,ALE6 C2SET PORT DATA
100EMOV AL,90B0 90WRITE DISPLAY
1010OUT C2,ALE6,C2CLEAR DISPLAY IN RAM
1012NEXTMOV AL,[SI]8A 04LOP FOR THE PRESSING OF KEY
1014OUT CO,ALE6 C0SET TO READ FIFO RAM
1016CALL DELAYE8 E7 04CALL DISPLAY DATA
1019INC SI46GET THE CORRESPONDING CODE FORM LOOKUP TABLE
101ALOOP NEXTE2 F6GO TO NEXT
101CJMP STARTEB E2JUMP START
SUB PROGARM:ADDRESS
LOOPMNEMONICSOP-CODECOMMANDS
1500 DELAYMOV DX,A0FFBA FF A0MOVE THE VALUE TODX REGISTER
1503DEC DX4ADECREMENT DX
1504JNZ LOOP175 FDJUMP NO ZERO
1506RETC3RETURN
LOOK-UP TABLEADDRESSDATA
1200FF,FF,FF,FF
1204FF,FF,FF,FF
120868,6C,68,FF
120CFF,38,FF,FF
EXPT NO: INTERFACING AND PROGRAMMING OF PRINTER INTERFACEUSING 8086DATE: AIM:To perform interfacing and programming Printer interface using 8086.
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3.Power chord1
4.50 channel bus3
5.Printer interface1
6.dot matrix Printer 1
PROGRAMADDRESSLABELMNEMONICSOPCODE
1000MOV AL,05HB0 05
1002OUT CONTL,ALE6 D0
1004IN AL,STUSE4 C0
1006AND AL,20H24 20
1008CMP AL,20H3C 20
100A JNZ ERR75 44
100C MOV AL,41H B0 41
100E CALL PRINT E8 06 00
1011MOV AL,0AHB0 0A
1013CALL PRINTE8 01 00
1016HLTF4
1017PRINT: MOV BL,AL8A D8
1019CALL CHECKE8 10 00
101C STAS: MOV AL,BL8A C3
101E OUT DATA,ALE6 C8
1020MOV AL,01HB0 01
1022OUT CONTL,ALE6 D0
1024NOP90
1025NOP90
1026NOP90
1027MOV AL,05HB0 05
1029OUT CONTL,ALE6 D0
102B RETC3
102C CHECK:IN AL,STUSE4 C0
102E AND AL,20H24 20
1030JZ CHECK74 FA
1032IN AL,STUSE4 C0
1034AND AL,80H24 80
1036CMP AL,80H3C 80
1038JNZ STAS 75 E2
103A JMP CHECKEB F0
103C HLTF4
1050ERR:INT 2CD 02
1052END
EXPT NO: SERIAL COMMUNICATION BETWEEN TWO MP KITS DATE: USING 8251AIM:To perform serial communication between two microprocessor kits using 8251.APPARATUS REQUIRED:
SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3.Power chord1
4.VXT parallel bus1
5.Interface board82511
6.Serial connection cableRS232
ALGORITHM:a) Connect the two serial ports with RS232 cable.b) First make the receiver end ready and then execute the program at transmitter end.c) The transmitter transmits the data serially.d) The receiver data is stored in the memory location given in the program.
TRANSMITTER PROGRAMADDRESSMNEMONICSOP-CODECOMMANDS
1000MOV AL,36BO 36MOVE THE VALUE TO ACCUMULATOR
1002OUT CE,ALE6 CESEND DATA TO OUTPUT PORT
1004MOV AL,10B0 10MOVE THE VALUE TO ACCUMULATOR
1006OUT C8,ALE6 C8SEND DATA TO OUTPUT PORT
1008MOV AL,00B0 00MOVE THE VALUE TO ACCUMULATOR
100AOUT C8,ALE6 C8 SEND DATA TO OUTPUT PORT
100CMOV AL,4EB0 4EMOVE THE VALUE TO ACCUMULATOR
100EOUT C2,ALE6 C2SEND DATA TO OUTPUT PORT
1010MOV AL,37B0 37MOVE THE VALUE TO ACCUMULATOR
1012OUT C2,ALE6 C2SEND DATA TO OUTPUT PORT
1014MOV AL,AABO AAMOVE THE VALUE TO ACCUMULATOR
1016OUT CO,ALE6 COSEND DATA TO OUTPUT PORT
1018INT 02CD 02INTERUPT
RECEIVER PROGRAMADDRESSMNEMONICSOP-CODECOMMANDS
1200IN AL,C0E4 C0INTERUPT
1202MOV BX[1250]BB 50 12MOVE THE VALUE TO ADDRESS
1205MOV BX,AL88 07MOVE ACCUMULATORDATA TO BX
1207INT 02CD 02INTERUPT
INTERFACING 8255 WITH 8086AIM:To interface programmable peripheral interface 8255 with 8086 and study its characteristics in mode0APPARATUS REQUIRED:1. 8086 p kit2. 8255 Interface board3. DC regulated power supply 4. VXT parallel bus I/O MODES:Control Word:
MODE 0 SIMPLE I/O MODE:This mode provides simple I/O operations for each of the three ports and is suitable for synchronous data transfer. In this mode, all the ports can be configured either as input or output port.Let us initialize port A as input port PROGRAM:ADDRESSLABELMNEMONICSOPCODES
1000MOV SI , 1500BE 00 15
1003MOV AL,90B0 90
1005OUT C6,ALE6 C6
1007IN AL,C0E4 C0
1009MOV [SI], AL88 04
100BHLTF4
MODE 0 STROBED I/O MODE:Let us initialize port A as input port and port B as output portPROGRAM:ADDRESSLABELMNEMONICSOPCODES
1000MOV AL,90B0 90
1002OUT C6,ALE6 C6
1004IN AL,C0E4 C0
1006OUT C2 ALE6 C2
1008HLTF4
RESULT:Thus 8255 are interfaced and their characteristic in mode0 was studied.
EXPT NO: PROGRAMS FOR INTERFACING ADC AND DACDATE: (USING 8086)
AIM:To write an Assembly Language Program (ALP) to interface ADC and DAC using 8086 microprocessor.
APPARATUS REQUIRED:SL.NOITEMSPECIFICATIONQUANTITY
1.Microprocessor kit8086 kit1
2.Keyboard1
3Power chord1
4.ADC kit1
5.Multimeter1
6.DAC kit1
7.50 channel Bus2
8.CRO1
9.CRO probe1
THEORY:ANALOG TO DIGITAL CONVERTER:ADC-0809 A/D card is an 8bit analog to digital converter with 8 channel multiplexer and microprocessor compatible control logic. The heart of the car is ADC-0809 monolithic C-MOS device. Its conversion time is 100 micro sec. it eliminates the need for external zero and full scale adjustment. The card selects one of the eight unipolar inputs by using the address decoder. ADC-0809 uses successive approximation as conversion techniques. Input is latched to the decoder on the low to high transition of the address latch enable signal. The conversion starts on the falling edge of the start of conversion signal. During the process end of conversion signal goes low otherwise it remains high. Digital output can be read from ADC making output enable signal high.Circuit description:The data line of ADC-0809 d0 to d7 is connected to port-A as input port. SOC is connected to PC0 as output port; EOC is connected to PC4 as input port & ALE is connected to PC1 as output port. All eight inputs of 0-5 volts ADC-0809 analog with external clock, external EOC, external SOC signals are brought to 26 pin connector. A clock input of a specified frequency is required for the operation of ADC-0809. A counter 74LS93 has been used for this purpose.Hardware installation: Connect ADC-0809 interfacing module to 8255-I of 8086 trainer kit through 26 pin FRC cable. Be sure about the direction of the cable i.e. pin NO.1 of module should be connected to pin NO.1 of 8255 connector. Connect +5v, GND from the trainer kit (+5v & GND signals are available in the 25 & 26 pin of FRC 8255-I connector)DIGITAL TO ANALOG CONVERTER:A digital number can be converted to an analog voltage by selectively adding voltage which is proportional to the weight of each binary digit. The module finds a great use in feedback system, like output of a channel is fed to a control circuit to contain output in the form of signal is observed at an oscilloscope or for a hard copy fed to an X-Y Recorder/X-T Recorder. Different wave forms can be generated by using this DAC-0800 module.Circuit description:Port A & port B are connected to channel 1 and channel 2 respectively. A reference voltage of 8V is generated using 723 and is given to verify points of the DAC 0800. The standard output voltage will be 7.98V when FF is outputted and will be 0v when 00 is outputted. The output of DAC-0800 is fed to the operational amplifier to get the final output as X out and Y out. Several interesting waveforms can be generated and observed on oscilloscope.Hardware installation: Connect DAC-0800 interfacing module to 8255-I of 8085/8051/80865 trainer kit through 26 pin FRC cable. Be sure about the direction of the cable i.e. pin No.1 of module should be connected to pin No.1 of 8255 connector. Connect +12V, -12V & GND from the trainer kit.ALGORITHM:ANALOG TO DIGITAL CONVERTER:a) Start the program.b) Enter the control word.c) Clear the register.d) Move the register at AL=0.e) Read EOC from Accumulator.f) Read 16 bit ADC data.g) Clear CALL display.h) CALL display routine.i) Load CX register as 0F0H.j) Jump till CX=0.k) Jump to start.l) Stop the program.DIGITAL TO ANALOG CONVERTER:1) GENERATION OF SAWTOOTH WAVEa) Start the programb) Load the input value to the accumulator.c) Move to C0.d) Increment AL.e) If jump on no carry then execute loop L1.f) Jump on START.g) Return.h) Store the output in the required memory location.i) Stop the program.
2) GENERATION OF SQUARE WAVEa) Start the programb) Load the input value to the accumulator.c) Call the delay.d) Jump on start.e) Go to loop L1.f) Return.g) Store the output in the required memory location.h) Stop the program.3) GENERATION OF TRAINGULAR WAVEa) Start the program.b) Load the value in the accumulator.c) Increment the BL register.d) Jump on no zero.e) Decrement the BL register.f) Jump on no carry.g) Return.h) Store the output in the required memory location.i) Stop the program.
PROGRAM:ANALOG TO DIGITAL CONVERTERADDRESSLABELMNEMONICS OP-CODECOMMANDS
1000MOV AL,03B0,03MOVE DATA TO ACCUMULATOR
1002OUT C8,ALE6,C8MOVE THE CONTENT OF AL TO OUTPUT PORT
1004MOV AL,23B0,23MOVE DATA TO ACCUMULATOR
1006OUT C8,ALE6,C8MOVE THE CONTENT OF AL TO OUTPUT PORT
1008MOV AL,03B0,03MOVE DATA TO ACCUMULATOR
100AOUT C8,ALE6,C8MOVE THE CONTENT OF AL TO OUTPUT PORT
100CMOV AL,01B0,01MOVE DATA TO ACCUMULATOR
100EOUT D0,ALE6,D0MOVE THE CONTENT OF AL TO OUTPUT PORT
1010MOV AL,00B0,00MOVE DATA TO ACCUMULATOR
1012OUT D0,ALE6,D0MOVE THE CONTENT OF AL TO OUTPUT PORT
1014LOOPIN AL,E0E4,E0MOVE THE CONTENT OF INPUT PORT TO AL
1016AND AL,0124,01PERFORM AND OPERATION WITH AL AND DATA
1018CMP AL,013C,01COMPARE THE VALUE OF AL WITH DATA
101AJNZ LOOP75,F8JUMP ON NO ZERO
101CIN AL,C0E4,C0MOVE THE CONTENT OF INPUT PORT TO AL
101EMOV BX,1100BB,00,11MOVE THE DATA TO BX
1021MOV[BX],AL88,07MOVE THE CONTENT OF AL TO BX
1023HLTF4STOP
DIGITAL TO ANALOG CONVERTER1. GENERATION OF SAWTOOTH WAVEADDRESSLABELMNEMONICSOP-CODECOMMANDS
1000STARTMOV AL,00B0,00MOVE THE DATA TO AL REGISTER
1002L1OUT C0,ALE6,C0MOVE THE CONTENT OF AL TO OUTPUT PORT C0
1004INC ALFE,C0INCREMENT AL REGISTER
1006JNZ L175,FAJUMP ON NO ZERO
1008JMP STARTEB,F6JUMP TO START
100ARETC3RETURN
2. GENERATION OF SQUARE WAVEADDRESSLABELMNEMONICSOPCODECOMMANDS
1000STARTMOV AL,00B0,00MOVE THE DATA TO AL REGISTER
1002OUT C0,ALE6,C0MOVE THE CONTENT OF AL TO OUTPUT PORT C8
1004CALL DELAYE8,09,00CALL THE DELAY PROGRAM
1007MOV AL,FFB0,FFMOVE THE DATA TO AL REGISTER
1009OUT C0,ALE6,C0MOVE THE CONTENT OF AL TO OUTPUT PORT C8
100BCALL DELAYE8,02,00CALL THE DELAY PROGRAM
100EJMP STARTEB,F0JUMP TO START
1010DELAYMOV CX,05,FFB9,FF,05DECLARE THE COUNT VALUE
1013L1LOOP L1E2,FEGO TO LOOP L1
1015RETC3RETURN
3. GENERATION OF TRAINGULAR WAVE
ADDRESSLABELMNEMONICSOP-CODECOMMANDS
1000STARTMOV BL,00B3,00MOVE THE DATA TO BASE REGISTER
1002L1MOV AL,BL88,D8MOVE THE CONTENT BL TO AL REGISTER
1004OUT C0,ALE6,C0MOVE THE CONTENT OF AL TO OUTPUT PORT C8
1006INC BLFE,C3INCREMENT THE VALUE OF BL REGISTER
1008JNZ L175,F8JUMP ON NO ZERO
100AMOV BL,FFB3,FFMOVE THE DATA TO BL REGISTER
100CL2MOV AL,BL88,D8MOVE THE CONTENT BL TO AL REGISTER
100EOUT C0,ALE6,C0MOVE THE CONTENT OF AL TO OUTPUT PORT C8
1010DEC BLFE,CBDECREMENT THE VALUE OF BL REGISTER
1012JNC L275,F8JUMP ON NO CARRY
1014JMP STARTEB,EAJUMP ON START
1016RETC3RETURN
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: aDATE:ADDITION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to add the two 8-bit numbers using microcontroller instruction set.
APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Add the second data with Accumulator.4. Store the sum in memory pointed by DPTR.PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100CLR CC3
6101MOV A,#data174, 3F
6103ADD A, #data224, 29
6105MOV DPTR, #6500H90, 65, 00
6108MOVX @DPTR, AF0
6109LOOPSJMP LOOP80, FE
OBSERVATIONINPUTOUTPUT
AddressDataAddressData
3F650068
29
RESULTThus, the assembly language program to add the two 8-bit numbers using 8051 instruction set was written and executed successfully.
1. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: bDATE:SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to subtract the two 8-bit numbers using microcontroller instruction set.APPARATUS REQUIRED1. 8051 microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Subtract the second data with Accumulator.4. Store the sum in memory pointed by DPTR.PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODECOMMENTS
6100CLR CC3
6101MOV A,#data174, 59
6103SUBB A, #data294, 28
6105MOV DPTR, #6500H90, 65, 00
6108MOVX @DPTR, AF0
6109LOOPSJMP LOOP80, FE
OBSERVATIONINPUTOUTPUT
AddressDataAddressData
59650031
28
RESULTThus, the assembly language program to subtract the two 8-bit numbers was written and executed successfully.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: cDATE:MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to multiply the two 8-bit numbers using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Move the second data to B-register.4. Multiply the second data with Accumulator.5. The higher order of the result is in B-register.6. The lower order of the result is in Accumulator.7. Store the sum in memory pointed by DPTR.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100CLR CC3
6101MOV A,#data174, 04
6103MOV B,#data275, F0, 02
6106MUL ABA4
6107MOV DPTR, #6500H90, 65, 00
610AMOVX @DPTR, AF0
610BINC DPTRA3
610CMOV A, BE5, F0
610EMOVX @DPTR, AF0
610FLOOPSJMP LOOP80, FE
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
06650018
04650100
RESULTThus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction set was written and executed
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: dDATE:DIVISION OF TWO 8-BIT NUMBERS USING 8051AIMTo write an assembly language program to divide the two 8-bit numbers using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Move the second data to B-register.4. Multiply the second data with Accumulator.5. The remainder of the result is in B-register.6. The quotient of the result is in Accumulator.7. Store the sum in memory pointed by DPTR.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100CLR CC3
6101MOV A,#data174, 08
6103MOV B,#data275, F0, 02
6106DIV AB84
6107MOV DPTR, #6500H90, 65, 00
610AMOVX @DPTR, AF0
610BINC DPTRA3
610CMOV A, BE5, F0
610EMOVX @DPTR, AF0
610FLOOPSJMP LOOP80, FE
OBSERVATIONINPUTOUTPUT
AddressDataAddressData
3F650002 (QU)
1E650103(RE)
RESULTThus, the assembly language program to divide the two 8-bit numbers using 8051 instruction set was written and executed successfully. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: eDATE:ONES AND TWOS COMPLEMENT USING 8051AIMTo write an assembly language program to find the 1s and 2s complement of an 8-bit number using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Move the data to Accumulator.2. Complement the accumulator.3. Move the ones complement output to the memory 6500H. 4. Add 01H with accumulator.5. Move the twos complement output to the memory 6501H. PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV A, #data74, CC
6101CPL AF4
6103MOV DPTR, #6500H90, 65, 00
6106MOVX @DPTR, AF0
6107INC A04
610AINC DPTRA3
610BMOVX @DPTR, AF0
610CLOOPSJMP LOOP80, FE
OBSERVATIONINPUTOUTPUT
AddressDataAddressData
CC650033
650134
RESULTThus the assembly language program to find the 1s and 2s complement of an 8-bit number using 8051 instruction set was written and executed successfully. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: fDATE:SETTING BITS IN AN 8 BIT NUMBERS USING 8051AIMTo write an assembly language program to find the Setting bits an 8-bit number using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Move the data to Accumulator.2. Perform OR operation with accumulator.3. Move the accumulator output to the memory 6500H. PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV A, #data174, 2F
6102ORL A, #data244, 7E
6104MOV DPTR, #6500H90, 65, 00
6107MOVX @DPTR, AF0
6108LOOPSJMP LOOP80, FE
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
2F65007F
7E
RESULTThus the assembly language program to Setting bits an 8-bit number using microcontroller instruction set was written and executed successfully. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: gDATE:MASKING BITS IN AN 8 BIT NUMBERS USING 8051AIMTo write an assembly language program to find the Masking bits an 8-bit number using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Move the data to Accumulator.2. Perform AND operation with accumulator.3. Move the accumulator output to the memory 6500H. PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV A, #data174, 2F
6102ANL A, #data254, 7E
6104MOV DPTR, #6500H90, 65, 00
6107MOVX @DPTR, AF0
6108LOOPSJMP LOOP80, FE
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
6500
RESULTThus the assembly language program to masking bits an 8-bit number using microcontroller instruction set was written and executed successfully.
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)EX NO: aDATE:ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER AIMTo write an assembly language program to sort an array of data in ascending order using 8051 simulator tool.APPARATUS REQUIRED8051 Microcontroller KitALGORITHM1. Load the count value from memory to A-register and store it in B-register.2. Decrement B-register (B is a count for (N-1) repetitions). 3. Set HL pair as data address pointer.4. Set C-register as counter for (N-1) comparisons.5. Load a data of the array in accumulator using the data address pointer.6. Increment the HL pair (data address pointer).7. Compare the data pointed by HL with accumulator.8. If carry flag is set (if the content of accumulator is smaller than memory) then go to step 10, otherwise, go to next step.9. Exchange the content of memory pointed by HL and the accumulator.10. Decrement C-register. If zero flag is reset go to step 6, otherwise, go to next step.11. Decrement B-register. If zero flag is reset go to step 3, otherwise, go to next step.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV R3, #04H7B, 04
6102MOV R4, #04H7C, 04
6104MOV DPTR, #6500H90, 65, 00
6107LOOP1MOV R5, DPLAD, 82,
6109MOV R6, DPHAE, 83
610BMOVX A, @DPTRE0
610CMOV B,AF5, F0
610ELOOPINC DPTRA3
610FMOVX A, @DPTRE0
6110MOV R0, AF8
6111CLR CC3
6112SUBB A, B95, F0
6114JNC LOOP250,13
6116EXCHPUSH DPLC0, 82
6118PUSH DPHC0, 83
611AMOV DPL, R58D, 82
611CMOV DPH, R68E, 83
611EMOV A, R0E8
611FMOVX @DPTR,AF0
6120POP DPHD0, 83
6122POP DPLD0, 82
6124MOV A, BE5, F0
6126MOVX @DPTR, AF0
6127MOV B, R088, FO
6129LOOP2DJNZ R3, REPTDB, E3
612BDEC R41C
612CMOV A, R4EC
612DMOV R3, AFB
612EINC R40C
612FMOV DPL, R58D, 82
6131MOV DPH, R68E, 83
6133INC DPTRA3
6134DJNZ R4, LOOP1DC, D1
6136HLTSJMP HLT80, FE
OBSERVATIONINPUT(Before sorting)OUTPUT(After sorting)
AddressDataAddressData
650005H650005H
65010AH650103H
650206H650206H
650303H650308H
650408H65040AH
RESULTThus, the assembly language program to sort an array of data in ascending order using 8051 simulator tools was written and executed successfully.PROGRAMS FOR SORTING AND SEARCHING (USING 8051)EX NO: bDATE:ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER AIMTo write an assembly language program to sort an array of data in descending order using 8051 simulator tool.APPARATUS REQUIRED8051 Microcontroller KitALGORITHM1. Load the count value from memory to A-register and store it in B-register.2. Decrement B-register (B is a count for (N-1) repetitions). 3. Set HL pair as data address pointer.4. Set C-register as counter for (N-1) comparisons.5. Load a data of the array in accumulator using the data address pointer.6. Increment the HL pair (data address pointer).7. Compare the data pointed by HL with accumulator.8. If carry flag is set (if the content of accumulator is smaller than memory) then go to step 10, otherwise, go to next step.9. Exchange the content of memory pointed by HL and the accumulator.10. Decrement C-register. If zero flag is reset go to step 6, otherwise, go to next step.11. Decrement B-register. If zero flag is reset go to step 3, otherwise, go to next step.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV R3, #04H7B, 04
6102MOV R4, #04H7C, 04
6104MOV DPTR, #6500H90, 65, 00
6107LOOP1MOV R5, DPLAD, 82,
6109MOV R6, DPHAE, 83
610BMOVX A, @DPTRE0
610CMOV B,AF5, F0
610ELOOPINC DPTRA3
610FMOVX A, @DPTRE0
6110MOV R0, AF8
6111CLR CC3
6112SUBB A, B95, F0
6114JNC LOOP240,13
6116EXCHPUSH DPLC0, 82
6118PUSH DPHC0, 83
611AMOV DPL, R58D, 82
611CMOV DPH, R68E, 83
611EMOV A, R0E8
611FMOVX @DPTR,AF0
6120POP DPHD0, 83
6122POP DPLD0, 82
6124MOV A, BE5, F0
6126MOVX @DPTR, AF0
6127MOV B, R088, F0
6129LOOP2DJNZ R3, REPTDB, E3
612BDEC R41C
612CMOV A, R4EC
612DMOV R3, AFB
612EINC R40C
612FMOV DPL, R58D, 82
6131MOV DPH, R68E, 83
6133INC DPTRA3
6134DJNZ R4, LOOP1DC, D1
6136HLTSJMP HLT80, FE
OBSERVATIONINPUT(Before sorting)OUTPUT(After sorting)
AddressDataAddressData
650005H650005H
65010AH65010CH
65020CH65020AH
650306H650308H
650408H650406H
RESULT Thus the assembly language program to sort an array of data in descending order using 8051 simulator tools was written and executed successfully.PROGRAMS FOR SORTING AND SEARCHING (USING 8051)EX NO: cDATE:LARGEST ELEMENT IN AN ARRAYAIMTo write an assembly language program to find the largest number in an array using 8051 simulator tools.APPARATUS REQUIRED8051 Microcontroller kit, Power chordALGORITHM1. Clear C-register for carry.2. Move the first data from memory to accumulator and move it to B-register.3. Move the second data from memory to accumulator.4. Add the content of B-register with Accumulator.5. Check for carry. If carry=1 then go to step 6 else go to step 7.6. Increment the C-register7. Store the sum in memory.8. Move the carry to accumulator and store in memory.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV DPTR,#650090, 65, 00
6103MOV 40,#0075, 40, 00
6106MOV R5,#057D, 05
6108LOOP2MOVX A,@DPTRE0
6109CJNE A,40H,LOOP1B5, 40, 08
610CLOOP3INC DPTRA3
610DDJNZ R5, LOOP2DD, F9
610FMOV A, 40HE5, 40
6111MOVX @DPTR,AF0
6112HLTSJMP HLT80, FE
6114LOOP1JC LOOP340, F6
6116MOV 40H,AF5, 40
6118SJMP LOOP380, F2
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
650004H65000AH
650108H
650202H
65030AH
650406H
RESULTThus the assembly language program to find the largest number in an array using 8051 simulator tools was written and executed successfullyPROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: gDATE:UNMASKED BCD NUMBER TO ASCII CODE USING 8051AIMTo write an assembly language program to find the Masking bits an 8-bit number using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Move the data to Accumulator.2. Perform OR operation with accumulator.3. Move the accumulator output to the memory 6500H. PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100MOV A, #data174, 02
6102ORL A, #3044, 30
6104MOV DPTR, #6500H90, 65, 00
6107MOVX @DPTR, AF0
6108LOOPSJMP LOOP80, FE
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
6500
RESULTThus the assembly language program to masking bits an 8-bit number using microcontroller instruction set was written and executed successfully.PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: cDATE:SQUARE OF A 8-BIT NUMBER USING 8051
AIMTo write an assembly language program to multiply the two 8-bit numbers using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Move the first data to B-register.4. Multiply the B-register with Accumulator.5. The higher order of the result is in B-register.6. The lower order of the result is in Accumulator.7. Store the sum in memory pointed by DPTR.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100CLR CC3
6101MOV A,#data174, 04
6103MOV B,AF5, F0
6105MUL ABA4
6106MOV DPTR, #6500H90, 65, 00
6109MOVX @DPTR, AF0
610AINC DPTRA3
610BMOV A, BE5, F0
610DMOVX @DPTR, AF0
610ELOOPSJMP LOOP80, FE
OBSERVATION
INPUTOUTPUT
AddressDataAddressData
06650024
650100
RESULTThus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction set was written and executed
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLEREX NO: cDATE:CUBE OF A 8-BIT NUMBER USING 8051
AIMTo write an assembly language program to multiply the two 8-bit numbers using microcontroller instruction set.APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.ALGORITHM1. Clear C-register for carry.2. Move the first data to Accumulator.3. Move the first data to B-register.4. Multiply the B-register with Accumulator.5. The higher order of the result is in B-register.6. The lower order of the result is in Accumulator.7. Store the sum in memory pointed by DPTR.
PROGRAMMEMORY ADDRESSLABELMNEMONICSOP CODE
6100CLR CC3
6101MOV A,#data174, 04
6103MOV B,AF5, F0
6105MOV R0, AF8
6106MUL ABA4
6107MOV F0,R0A8, F0
6109MUL ABA4
610AMOV DPTR, #6500H90, 65, 00
610DMOVX @DPTR, AF0
610EINC DPTRA3
6110MOV A, BE5, F0
6112MOVX @DPTR, AF0
6113LOOPSJMP LOOP80, FE
OBSERVATIONINPUTOUTPUT
AddressDataAddressData
0F65002F
65010D
RESULTThus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction set was written and executed