MPMC Lab Manual EEE PDF
MPMC Lab Manual EEE PDF
MPMC Lab Manual EEE PDF
OBSERVATION MANUAL
FOR
MICROPROCESSORS AND
MICROCONTROLLERS LAB
FOR B.TECH III YEAR I SEMESTER
ROLL NO.:
SECTION:
Course objectives:
This course is intended to
Introduce the basic concepts of microprocessor and Microcontrollers.
Develop in students the assembly language programming skills and real time
applications of Microprocessor as well as microcontroller.
Understand how different I/O devices can be interfaced to Microprocessors.
Course Outcomes: After undergoing the lab course students will be able to
Apply the fundamentals of assembly level programming of microprocessors and
microcontrollers.
Analyze abstract problems and apply a combination of hardware and software to address
the problem
Contrast how different I/O devices can be interfaced to processor and will explore
several techniques of interfacing.
Experiment with standard microprocessor interfaces including serial ports, digital-to-
analog converters and analog-to-digital converters.
SYLLABUS
1. Programs for 16 bit arithmetic operations for 8086 (using Various Addressing Modes).
2. Program for sorting an array for 8086.
3. Program for searching for a number or character in a string for 8086.
4. Program for string manipulations for 8086.
5. Program for digital clock design using 8086.
6. Interfacing ADC and DAC to 8086.
7. Parallel communication between two microprocessors using 8255.
8. Serial communication between two microprocessor kits using 8251.
9. Interfacing to 8086 and programming to control stepper motor.
10. Programming using arithmetic, logical and bit manipulation instructions of 8051.
11. Program and verify Timer/Counter in 8051.
12. Program and verify Interrupt handling in 8051.
13. UART Operation in 8051.
14. Communication between 8051 kit and PC.
15. Interfacing LCD to 8051.
16. Interfacing Matrix/Keyboard to 8051.
17. Data Transfer from Peripheral to Memory through DMA controller 8237/8257.
INDEX
S.No. NAME OF THE EXPERIEMNT Page No. Remarks
ADDITIONAL EXPERIEMNTS
8 Program to find number of Even and Odd numbers in a given array. 117
8086 ARCHITECTURE:
PIN DIAGRAM:
Logical Instructions
NOT : Logical NOT of byte or word (one's complement)
AND : Logical AND of byte or word
OR : Logical OR of byte or word
XOR : Logical exclusive-OR of byte or word
TEST : Test byte or word (AND without storing)
Arithmetic Instructions
ADD SUB : Add, subtract byte or word
ADC SBB : Add, subtract byte or word and carry (borrow)
INC DEC : Increment, decrement byte or word
NEG : Negate byte or word (two's complement)
CMP : Compare byte or word (subtract without storing)
MUL DIV : Multiply, divide byte or word (unsigned)
IMUL IDIV : Integer multiply or divide byte or word (signed)
CBW CWD : Convert byte to word, word to double word (useful before
multiply/divide)
AAA,AAS,AAM,AAD: ASCII adjust for addition, subtraction, multiplication,
division (ASCII codes 30-39)
DAA, DAS : Decimal adjust for addition, subtraction (binary coded
decimal numbers)
Transfer Instructions
JMP : Unconditional jump
JA (JNBE) : Jump if above (not below or equal)
JAE (JNB) : Jump if above or equal (not below)
JB (JNAE) : Jump if below (not above or equal)
JBE (JNA) : Jump if below or equal (not above)
JE (JZ) : Jump if equal (zero)
JG (JNLE) : Jump if greater (not less or equal)
JGE (JNL) : Jump if greater or equal (not less)
JL (JNGE) : Jump if less (not greater nor equal)
JLE (JNG) : Jump if less or equal (not greater)
INTRODUCTION TO MASM
MS-MASM:
Microsoft’s Macro Assembler (MASM) is an integrated software package Written by
Microsoft Corporation for professional software developers. it consists of an editor, an
assembler, a linker and a debugger(Code View). The programmer’s workbench
combines these four parts into a user-friendly programming environment with built in on
line help. The following are the steps used if you are to run MASM from DOS.
Summarized basic DOS - Debugger commands.
EDITOR:
An editor is a program, which allows you to create a file containing the assembly
language statements for your program. As you type in your program the editor stores the
ASCII codes for the letters and numbers in successive RAM locations. When you have
typed in all of your programs you then save the file on a floppy of hard disk. This file is
called source file. The next step is to process the source file with an assembler. In the
MASM/TASM assembler you should give your source file name the extension .ASM
ASSEMBLER:
An assembler program is used to translate the assembly language mnemonics for
instructions to the corresponding binary codes. When you run the assembler it reads the
source file of your program from the disk where you saved it after reading on the first pass
through the source program, the assembler determines the displacement of named data
items, the offset of labels and this information is stored on a symbol table. On the second
pass through the source program, the assembler produces the binary code for each
instruction and inserts the offset etc that was calculated during the first pass. The
assembler generates two files on floppy or hard disk. The first file called the object file
is given the extension. OBJ. The object file contains the binary codes for the
instructions and information about the addresses of the instructions. The second file
generated by the assembler is called assembler list file. The list file contains your
assembly language statements the binary codes for each instructions and the offset
for each instruction. In MASM/TASM assembler MASM source file name ASM is
used to assemble the file. Edit source file name LST is used to view the list file which is
generated, when you assemble the file.
LINKER:
A linker is a program used to join several object files into one large object file and
convert it to an exe file. The linker produces a link file, which contains the binary codes for
all the combined modules. The linker however doesn’t assign absolute addresses to the
program, it assigns is said to be re-locatable because it can be put anywhere in
memory to be run. In TASM/MASM LINK source filename is used to link the file.
DEBUGGER:
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot or debug it. The debugger allows you to
look at the contents of registers and memory locations after your program runs. It allows
you to change the contents of register and memory locations after your program runs. It
allows you to change the contents of register and memory locations and return the
program. A debugger also allows you to set a break point at any point in the
program. If you inset a breakpoint the debugger will run the program up to the
instruction where the breakpoint is set and stop execution. You can then examine
register and memory contents to see whether the results are correct at that point. In
MASM, MD filename is used to debug the file.
DEBUGGER FUNCTIONS:
COMMAND SYNTAX
Assemble A [address]
Compare C range address
Dump D [range]
Enter E address [list]
Fill F range list
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Load L[address] [drive][first sector][number]
Move M range address
Name N[pathname][argument list]
Output O port byte
Proceed P [=address][number]
Quit Q [Quit]
Register R[register]
Search S range list
Trace T [=address][value]
Unassembled U [range]
Write W [address}[drive][first sector][number]
STEP1: Opening DOS prompt, Click on start menu button and click on Run and then
type CMD at command prompt DOS window will be appeared.
STEP2: Checking the MASM installation. To know MASM is installed or not simply
type MASM at the command prompt Upon that it replies MASM version vendor
(Microsoft), etc., If you get any error there is no MASM in that PC.
STEP3: Directory changing (create a folder with your branch and not in C drive)
Change the current directory to your own directory suppose your folder in D drive type
the following commands to change the directory at command prompt type D: hit enter,
now you are in D drive type cd folder name hit the enter.
Ex. D: cd MASM/ECEA
Now we are in folder ECEA
STEP4: writing the program. At the command prompt type the edit programname.asm
Ex. Edit add1.asm
Immediately editor window will be opened. Type the program in that window. After
completion, save the program. To save the program, go to file opt in the menu bar and
select save opt now your code is ready to assemble.
STEP5: Assembling, linking and executing the program Go to file opt& click exit opt.
Now DOS prompt will be displayed ,to assemble the program type the following
commands at the DOS prompt MASM program name, program name, program name hit
the enter.
Ex. MASM add1.asm;
If there are any errors in the program assembler reports all of them at the command
prompt with line no’s, if there are no bugs you are ready to link the program. To link the
program type the following line at command prompt.
Link program name
Ex. Link add1.Obj;
After linking to execute the program type the following command
Debug programname.exe hit the enter
Ex. Debug add1.exe
To execute the program, instruction by instruction (debugging) first of all press the R
key (register) hit the enter key, it’ll displays all the registers and their initial values in
HEXADECIMAL note down the values of all the register which are used in the
program. To execute the next instruction press t key (TRACE) hit the enter it’ll execute
that instruction and displays the contents of all the register. You have to do this until you
reach the last instruction of the program. After execution you have to observe the results
(in memory or registers based on what you have written in the program).
EXPERIMENT 1
Programs for 16 bit arithmetic operations for 8086 (using Various Addressing
Modes).
PROGRAM 1 (A): 16-bit Numbers Addition/Subtraction using Immediate Addressing
Mode
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
Start:
MOV AX, 1235
ADD AX, 4683 ; SUB for Subtraction
INT 03H
CODE ENDS
END Start
OUTPUT:
FLOW CHART:
PROGRAM:
CODE SEGMENT
Start: MOV AX, DATA // Initialization of data segment
MOV DS, AX
MOV AX, 0000H // XOR AX, AX
MOV AX, N1
ADD AX, N2 // Direct Addressing Mode
MOV SUM, AX
MOV AX, N1
SUB AX, N2
MOV DIFF, AX
MOV AX,N1
MOV BX,N2
MUL BX // Register
MOV MULT 1, AX
MOV MULT 2, DX
MOV AX, N1
MOV BX, N2
XOR DX, DX
DIV BX
MOV REM, DX
MOV QUO, AX
INT 03H
CODE ENDS
END Start
OUTPUT:
FLOW CHART:
PROGRAM:
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 2
PROGRAM FOR SORTING AN ARRAY FOR 8086
FLOW CHART:
PROGRAM:
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 3
PROGRAM FOR SEARCHING FOR A NUMBER OR CHARACTER IN A
STRING FOR 8086.
FLOW CHART:
PROGRAM:
OUTPUT:
PROGRAM 3 (B): Searching for a character in a string and displaying the outcome for
8086
FLOW CHART:
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
STR1 DB “PROCESSOR$”
LEN EQU ($-STR1)
STR2 DB “CHARACTER FOUND$”
STR3 DB “CHARACTER NOT FOUND$”
ABC MACRO X // DOS function call of INT 21H
LEA DX, X // MACRO is similar to that of printf, It is used for displaying string
MOV AH, 09H
INT 21H
ENDM
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
LEA SI, STR1
MOV AL, ‘A’
MOV CX, LEN
L1:
CMP AL, [SI]
JE L2
INC SI
LOOP L1 // LEA DX, STR3
ABC STR3 // MOV AH, 09H
INT 03H // INT 21H
L2:
ABC STR2
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 4
PROGRAM FOR STRING MANIPULATIONS FOR 8086.
OBJECTIVE: To write an assembly language program to display string and reverse the
given string.
FLOW CHART:
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
STR DB 'VIGANA$'
LEN EQU $-STR
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
LEA SI,STR
MOV CX,LEN-1
MOV DX,OFFSET STR // LEA DX, STR
MOV AH,09H // DOS function call for displaying a string
INT 21H
MOV AH, 2
MOV DL, 10 // /r ASCII value for return to zero
INT 21H
MOV AH, 2
MOV DL, 13 // /n ASCII value for new line
INT 21H
ADD SI,CX
DEC SI
BACK:
MOV DL,[SI]
MOV AH,02H
INT 21H
DEC SI
LOOP BACK
INT 3H
CODE ENDS
END START
OUTPUT:
FLOW CHART:
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: EXTRA
DATA SEGMENT
STRING1 DB 'EMPTY VESSELS MORE NOISE$'
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
STRING2 DB STRLEN+6 DUP (00)
EXTRA ENDS
CODE SEGMENT
START:MOV AX, DATA
MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
MOV SI, OFFSET STRING1
MOV DI, OFFSET STRING2
CLD
MOV CX, 14
REP MOVSB
MOV DL, 5
BACK: MOV AH, 01
INT 21H
STOS STRING2
DEC DL
JNZ BACK
MOV CX, 11
REP MOVSB
INT 3H
CODE ENDS
END START
OUTPUT:
FLOW CHART:
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: EXTRA
DATA SEGMENT
STRING1 DB 'MICROPROCESSORS ANDD MICROCONTROLLERS$'
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
STRING2 DB STRLEN-1 DUP (0)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
MOV SI, OFFSET STRING1
MOV DI, OFFSET STRING2
CLD
MOV CX, 19
REP MOVSB
CLD
INC SI
MOV CX, 18
REP MOVSB
INT 3H
CODE ENDS
END START
OUTPUT:
FLOW CHART:
PROGRAM:
ASSUME CS:CODE, DS:DATA, ES:EXTRA
DATA SEGMENT
STRING1 DB 'EMPTY'
STRLEN EQU ($-STRING1)
NOTSFUL DB 'STRINGS ARE UNEQUAL$'
SFUL DB 'STRINGS ARE EQUAL$'
DATA ENDS
EXTRA SEGMENT
STRING2 DB 'EMVTY'
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
MOV SI, OFFSET STRING1
MOV DI, OFFSET STRING2
CLD
MOV CX, STRLEN
REP CMPSB
JE FORW
MOV AH, 09H
MOV DX, OFFSET NOTSFUL
INT 21H
JMP EXITP
FORW:MOV AH,09H
MOV DX, OFFSET SFUL
INT 21H
EXITP:
NOP
MOV AH, 4CH
INT 21H
INT 3H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
4. Define Pipelining?
EXPERIMENT 5
PROGRAM FOR DIGITAL CLOCK DESIGN USING 8086.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
STR1 DB 'S$'
STR2 DB 'M$'
STR3 DB 'H$'
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
XOR DX,DX
L1:XOR AX,AX
XOR BX,BX
XOR CX,CX
XOR DI,DI
L2:CALL DELAY
LEA DX,STR1
MOV AH,09H
INT 21H
INC BL
CMP BL,59D
JNZ L2
LEA DX,STR2
MOV AH,09H
INT 21H
XOR BL,BL
INC BH
INT 03H
CMP BH,59D
JNZ L2
LEA DX,STR3
MOV AH,09H
INT 21H
XOR BH,BH
INC DI
CMP DI,23D
JNZ L2
JMP L1
DELAY PROC NEAR
MOV SI,7
X1:MOV CX,0FFFFH
X2:NOP
NOP
LOOP X2
DEC SI
JNZ X1
RET
DELAY ENDP
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What is the use of HLDA?
6) If the Trainer is connected to COM1 port on your Host PC & configured for 9600- baud
rate, click No. Click Yes otherwise. If yes, you will see the following dialog box.
7) Select the BaudRate as per the dipswitch configuration on ESA86-2 Trainer. Select the
Com Port where the trainer is connected. Click Apply. You should then see the
following window. Win86-2 User Manual Page 7 of 9
8) In some cases if the communication is not established you will see the following dialog
box. In this case please check the Power on ESA86-2 Trainer. Check whether Serial
cable is connected to the PC & ESA86-2 Trainer and check the parameter by clicking
Settings.
9) If the communication is established properly, from the displayed window you can work
with ESA86-2 Trainer. You can view the Registers, Memory Dumps, Download the hex
images, Upload the hex dump to the Host PC, Run the downloaded hex images, single
stepping, breakpoints, watch windows, Memory modification etc.,
These options are explained in detail in online help of Win86-2 (Win86-2.hlp).
TROUBLE SHOOTING:
1) Check the PC Serial Port working condition.
2) Check the Serial Cable working condition.
3) Check ESA86-2 Trainer Kit for Signon message (On LED).
4) Dipswitch Settings
NOTE: Same Way Windows Driver for ESA31 Trainer (WIN31) can be used to
interface 8051 (ESA31) Trainer kit with PC.
EXPERIMENT 6
INTERFACING ADC AND DAC TO 8086.
PROGRAM 6 (A): INTERFACING ADC TO 8086
TOOLS REQUIRED: 8086 trainer kit with power adapter, ADC interfacing board, PC
With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS: CODE
CODE SEGMENT
ORG 2000H
START:MOV DX,0FFE6H
MOV AL,8BH
OUT DX,AL
MOV AL,10H
MOV DX,0FFE0H
OUT DX,AL
NOP
NOP
MOV AL,00H
OUT DX,AL
MOV DX,0FFE4H
L1:IN AL,DX
AND AL,00H
JNZ L1
L2:IN AL,DX
AND AL,01H
JNZ L2
MOV DX,0FFE0H
MOV AL,40H
OUT DX, AL
MOV DX, 0FFE2H
IN AL,DX
INT 03H
CODE ENDS
END START
OUTPUT:
TOOLS REQUIRED: 8086 trainer kit with power adapter, DAC interfacing board,
CRO, PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START: MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
L1: MOV AL,00H
OUT DX,AL
CALL DELAY
MOV AL,0FFH
OUT DX,AL
CALL DELAY
JMP L1
DELAY PROC NEAR
MOV CX,4005H
X1:NOP
NOP
LOOP X1
RET
DELAY ENDP
INT 03H
CODE ENDS
END START
OUTPUT:
TOOLS REQUIRED: 8086 trainer kit with power adapter, DAC interfacing board,
CRO, PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START: MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
X: MOV AL,00H
L1:OUT DX,AL
INC AL
CMP AL,0FFH
JNE L1
L2:OUT DX,AL
DEC AL
CMP AL,00H
JNE L2
JMP X
INT 03H
CODE ENDS
END START
OUTPUT:
TOOLS REQUIRED: 8086 trainer kit with power adapter, DAC interfacing board,
CRO, PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 3000H
N DB 75H, 95H, 0AAH, 0BFH, 0D1H, 0E0H, 0EDH, 0F6H, 0FCH, 0FEH, 0FCH,
0F6H, 0EDH, 0E0H, 0D1H, 0BFH, 0AAH, 95H, 75H, 69H, 54H, 40H, 2DH, 1EH, 11H,
08H, 02H, 00H, 02H, 08H, 11H, 1EH, 2DH, 40H, 54H, 69H
ORG 2000H
START: MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
BACK: MOV CX,24H
MOV SI, 3000H
L1: MOV AL,[SI]
OUT DX,AL
INC SI
DEC CX
JNZ L1
JMP BACK
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 7
PARALLEL COMMUNICATION BETWEEN TWO MICROPROCESSORS
USING 8255
.
PROGRAM 7 (A): PARALLEL COMMUNICATION BETWEEN TWO MICROPROCESSORS
USING 8255.
TOOLS REQUIRED: 8086 trainer kit with power adapter, Dual DAC kit, CRO, PC
With installed Windows 7, DOSBOX and MASM.
THEORY: The parallel input-output port chip 8255 is also called as Programmable
peripheral input-output Port. The Intel’s 8255 are designed for use with Intel’s 8 -bit, 16-
bit and higher capability microprocessors. It has 24 input/output lines which may be
individually programmed in 2-groups of 12 lines each, or 3 groups of 8 lines .The two
groups of I/O pins are named as GROUP A and GROUP B. Each of these two groups
contain a sub group of 8 I/O lines called as 8-bit Port and other sub group of 4 I/O lines
are a 4-bit port. Thus GROUP A Contains an 8-bit port A along with a 4-bit port, C
upper. Port lines are identified by symbols PAO-PA7, While the port C lines are
identified as PC4-PC7 .Similarly group B contains an 8-bit port B, containing lines PB0-
PB7 and a 4-bit port C with lower bits PC0-PC3 .The port C upper and port C lower can
be used in recombination as an 8-bit port-C .Both the port Cs are assigned the same
address. Thus one may have either Three 8-bit I/O ports are two 8-bit and two 4-bit I/O
ports from 8255.All of these ports can function independently either as input or as output
ports. This can be achieved by programming the bits of an internal register of 8255
called as Control word register. (CWR).
FLOW CHART:
PROGRAM:
Transmitter side:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START: MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV AL,73H
MOV DX, 0FFE0H
OUT DX,AL
INT 03H
CODE ENDS
END START
Receiver side:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START: MOV DX,0FFE7H
MOV AL,9BH
OUT DX,AL
MOV DX, 0FFE1H
IN AL, DX
MOV BL,AL
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What is a stack?
4. ̅̅̅̅̅̅̅ ?
What is the function of 𝐼𝑁𝑇𝐴
EXPERIMENT 8
SERIAL COMMUNICATION BETWEEN TWO MICROPROCESSOR KITS
USING 8251.
.
PROGRAM 8 (A): SERIAL COMMUNICATION BETWEEN TWO MICROPROCESSORS
USING 8251 USART
TOOLS REQUIRED: 8086 trainer kit with power adapter, PC With installed
Windows 7, DOSBOX and MASM.
THEORY:
RXC (Input terminal): This is a clock input signal which determines the transfer speed
of received data. In "synchronous mode," the baud rate is the same as the frequency of
RXC. In "asynchronous mode," it is possible to select the baud rate factor by mode
instruction. It can be 1, 1/16, 1/64 the RXC.
DSR (Input terminal): This is an input port for MODEM interface. The input status of
the terminal can be recognized by the CPU reading status words.
DTR (Output terminal): This is an output port for MODEM interface. It is possible to
set the status of DTR by a command.
CTS (Input terminal): This is an input terminal for MODEM interface which is used
for controlling a transmit circuit. The terminal controls data transmission if the device is
set in "TX Enable" status by a command. Data is transmittable if the terminal is at low
level.
RTS (Output terminal): This is an output port for MODEM interface. It is possible to
set the status RTS by a command.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START: MOV AL,36
MOV DX,0086H
OUT DX,AL
MOV DX,0080H
MOV AL,0A
OUT DX,AL
MOV AL,00
OUT DX,AL
MOV SP,3000
MOV DX,0092
OUT DX,AL
OUT DX,AL
OUT DX,AL
OUT DX,AL
CALL 205F
MOV AL,40
OUT DX,AL
CALL 205F
MOV AL,CE
OUT DX,AL
CALL 205F
MOV AL,27
OUT DX,AL
CALL 205F
MOV SI,2100
MOV DX,0092
IN AL,DX
CMP AL,1B
JE 2031
MOV DX,0090
IN AL,DX
AND AL,81
CMP BL,AL
JE 205E
MOV DX,0092
IN AL,DX
AND AL,81
CMP AL,81
JNE 2043
MOV AL,BL
MOV DX,0090
OUT DX,AL
OUT DX,AL
MOV [SI],AL
INC SI
JMP 2031
OUT DX,AL
INC SI
JMP 2043
INT 03
MOV CX,0002
LOOP 2062
RET
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
4. What is USART?
EXPERIMENT 9
INTERFACING TO 8086 AND PROGRAMMING TO CONTROL STEPPER MOTOR
.
PROGRAM 9 (A): INTERFACING TO 8086 AND PROGRAMMING TO CONTROL STEPPER
MOTOR FOR TWO ROTATIONS IN CLOCKWISE DIRECTION WITH 10 rpm SPEED.
TOOLS REQUIRED: 8086 trainer kit with power adapter, Stepper motor interface kit,
PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START:
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,88H
MOV BX,400D
L1:
OUT DX,AL
CALL DELAY
ROR AL,01
DEC BX
JNZ L1
DELAY PROC NEAR
MOV CX,8008D
L2:
NOP
NOP
LOOP L2
RET
DELAY ENDP
INT 03H
CODE ENDS
END START
OUTPUT:
TOOLS REQUIRED: 8086 trainer kit with power adapter, Stepper motor interface kit,
PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START:
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,88H
L1:
OUT DX,AL
CALL DELAY
ROL AL,01
JMP L1
DELAY PROC NEAR
MOV CX, 8008D
L2:
NOP
NOP
LOOP L2
RET
DELAY ENDP
INT 03H
CODE ENDS
END START
OUTPUT:
TOOLS REQUIRED: 8086 trainer kit with power adapter, Stepper motor interface kit,
PC With installed Windows 7, DOSBOX and MASM.
FLOW CHART:
PROGRAM:
ASSUME CS:CODE
CODE SEGMENT
ORG 2000H
START:
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,88H
MOV BL, 100D
L1: OUT DX,AL
CALL DELAY
ROR AL,01
DEC BL
JNZ L1
NOP
NOP
MOV BH, 50D
L2: OUT DX,AL
CALL DELAY
ROL AL,01
DEC BH
JNZ L2
DELAY PROC NEAR
MOV CX,8669D
L3: NOP
NOP
LOOP L3
RET
INT 03H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. Explain the principle of stepper motor.
3) Create a new folder and Name it OurFirstProject. Type the name ourFirstProject for
the project and click Save.
4) In the Data base tree, choose the vendor and then the chip you want to use and then click
OK. For example, if you want to use the LPC2368, click on the NXP and then on the
LPC2368 and then press OK.
5) Click the YES button to add the startup file to the project.
6) Make a new file by clicking on the New Icon (you can make a new file by pressing
Ctrl+N or choosing New from the File menu, as well.)
7) Press Ctrl+S to save the new file. (You can also save the file by choosing Save from the
File menu.)
b. Then go to the OurFirstProject directory and choose Program.asm, press Add and
then Close.
Building
11) To compile click on the Build icon or choose build target from the Project menu.
13) To start debugging click on Start/Stop Debug Session icon or choose Start/Stop Debug
Session from the Debug menu. (or simply press Ctrl+F5)
14) If it starts tracing successfully, a cursor appears in front of the next instruction to be
executed.
15) Go to the Peripherals menu. It has tools for monitoring different peripherals. We can
see values of registers while tracing the program or change their values by clicking on
each bit.
16) To trace the program use the Step Over button or click on Step Over from the Debug
menu. It executes the instructions of the program one after another. To trace the program
you can use the Step button, as well. The difference between the Step Over and Step is in
executing functions. While Step goes into the function and executes its instructions one
by one, Step Over executes the function completely and goes to the instruction next to
the function. To see the difference between them, trace the program once with Step Over
and then with Step. When you are in the function and you want the function to be
executed completely you can use Step Out. In the case, the instructions of the function
will be executed, it returns from the function, and goes to the instruction which is next to
the function call.
17) To exit from the debugging mode press Start/Stop Debug Session.
EXPERIMENT 10
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051.
PROGRAM 10 (A): PROGRAMS FOR ARITHMETIC OPERATIONS
FLOW CHART:
PROGRAM:
MOV R0,#50
MOV A,#23H
MOV B,#12H
ADD A,B
MOV @R0,A
MOV A,#25H
MOV B,#16H
SUBB A,B
INC R0
MOV @R0,A
MOV A,#06H
MOV B,#05H
MUL AB
INC R0
MOV @R0,A
MOV A,#06
MOV B,#05
DIV AB
INC R0
MOV @R0,A
INC R0
MOV @R0,B
LCALL 0003
END
OUTPUT:
FLOW CHART:
PROGRAM:
1. AND LOGIC OPERATION
MOV A,#32H
MOV B,#23H
ANL A,B
X: SJMP X
END
2. OR LOGIC OPERATION
MOV A,#32H
MOV B,#23H
ORL A,B
X: SJMP X
END
4. COMPLIMENT OPERATION
MOV A,#32H
CPL A
X: SJMP X
END
5. SWAPING OPERATION
MOV A,#32H
SWAP A
X: SJMP X
END
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What amount of external memory supported to 8051 microcontroller?
2. Explain CLR?
EXPERIMENT 11
PROGRAM AND VERIFY TIMER/COUNTER IN 8051
PROGRAM 11 (A): PROGRAM AND VERIFY TIMER/COUNTER IN 8051
FLOW CHART:
PROGRAM:
ORG 0000H
RPT:
MOV TMOD,#15H
SETB P3.4
MOV TL0,#00H
MOV TH0,#00H
SETB TR0
MOV R0,#70
AGAIN:
MOV TL1,#00
MOV TH1,#00
SETB TR1
BACK:
JNB TF1,BACK
CLR TF1
CLR TR1
DJNZ R0,AGAIN
CPL P3.0
MOV A,TL0
MOV P2,A
SJMP RPT
END
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What is DJNZ?
4. What is TR0/TR1?
5. What is TF0/TF1?
EXPERIMENT 12
PROGRAM AND VERIFY INTERRUPT HANDLING IN 8051
PROGRAM 12 (A): PROGRAM AND VERIFY TIMER/COUNTER IN 8051(EXAMPLE-1)
FLOW CHART:
PROGRAM:
ORG 0000H
LJMP MAIN
ORG 000BH
CPL P1.2
RETI
ORG 0030H
MAIN:
MOV TMOD,#02H
MOV TH0,#0B6H
MOV IE,#82H
SETB TR0
BACK:
MOV P0, #'A'
MOV P2, #'B'
SJMP BACK
END
OUTPUT:
FLOW CHART:
PROGRAM:
ORG 0000H
LJMP MAIN
ORG 0003H
LED1:
MOV P0,#00H
MOV R0,#0255
DJNZ R0,LED1
RETI
ORG 0013H
LED2:
MOV P2,#00H
MOV R0,#0255
DJNZ R0,LED2
RETI
ORG 0030H
MAIN:
MOV IE,#85H
HERE:SJMP HERE
END
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What is 8253 ?
5. Which timer is used to set the baud rate for serial communication in 8051?
EXPERIMENT 13
UART OPERATION IN 8051
PROGRAM 13 (A): SERIAL COMMUNICATION - UART OPERATION IN 8051
FLOW CHART:
PROGRAM:
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
AGAIN:
MOV SBUF, #'M'
HERE:
JNB TI,HERE
CLR TI
MOV SBUF, #'P'
HERE1:
JNB TI,HERE1
CLR TI
MOV SBUF, #'M'
HERE2:
JNB TI,HERE2
CLR TI
MOV SBUF, #'C'
HERE3:
JNB TI,HERE3
CLR TI
X:SJMP X
END
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. ________________ helps the programmer in selecting the sources of interrupts.
2. The 8051 micro controller having __________ number of Interrupt pins.
3. If IP register has only the default priorities then Timer overflow have the
____________ priority
4. In 8051 instruction set OV flag affects for _____________ operations.
5. Difference between BSR and IO modes?
EXPERIMENT 14
COMMUNICATION BETWEEN 8051 KIT AND PC
PROGRAM 14 (A): COMMUNICATION BETWEEN 8051 KIT AND PC
TOOLS REQUIRED: 8051 Trainer kit and PC with installed Keil µVision IDE - MDK
plus.
FLOW CHART:
PROGRAM:
MOV A,#36
MOV DPTR,#2043
MOVX @DPTR,A
MOV DPTR,#2040
MOV A,#0A
MOVX @DPTR,A
MOV A,#00
MOVX @DPTR,A
MOV R1,#3000
MOV DPTR,#0092
MOVX @DPTR,A
MOVX @DPTR,A
MOVX @DPTR,A
MOVX @DPTR,A
CALL DELAY
MOV A,#40
MOVX @DPTR,A
CALL DELAY
MOV A,#CE
MOVX @DPTR,A
CALL DELAY
MOV A,#27
MOVX @DPTR,A
CALL DELAY
MOV DPTR,9000
MOV DPTR,#0092
UP:MOVX @DPTR,A
CMP A,1B
JE UP
MOV DPTR,#0090
MOVX @DPTR,A
ANL A,81
CJNE B,A.DOWN
MOV DPTR,#0092
UP1:MOVX @DPTR,A
ANL A,81
CJNE AL,81.UP1
MOV A,B
MOV DPTR,#0090
MOVX @DPTR,A
MOVX @DPTR,A
MOV R3,9700
MOV R3,A
INC R3
JMP UP
MOVX @DPTR,A
INC R3
JMP UP
INT 03
DOWN:MOV CX,0002
DELAY:
HERE:LOOP HERE
RET
EXAMPLE:2
MOV TMOD, #20H ;set timer1 in 16 bit timer mode
MOV TH1, #0FDH ;initialize serial communication
MOV TH1, #0FDH
MOV SCON, #40H ;load timer 1 to generate baud rate of 96KBps
SETB TR1 ;start timer 1
AGAIN:
SETB REN ;enable reception
X1: CLP RI
CJNZ X1 ;wait until data is received
CLR RI ;clear receive flag
MOV A, SBUF ;get data in to acc
CLR REN ;now disable reception
MOV SBUF, A ;start transmission
X2: CLP TI
CJNZ X2 ;wait until data transmitted
CLR TI ;clear transmission flag
SJMP AGAIN
END
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 15
INTERFACING LCD TO 8051
PROGRAM 15 (A): INTERFACING LCD TO 8051
TOOLS REQUIRED: 8051 Trainer kit, LCD Module and PC with installed Keil
µVision IDE - MDK plus.
FLOW CHART:
PROGRAM:
CNTRL EQU 2043H ; 8255 control port address
PORTC EQU 2042H ; 8255 port C address
PORTB EQU 2041H ; 8255 port B address
PORTA EQU 2040H ; 8255 port A address
FUNCTION_SET EQU 38H ; display commands
DIS_ON_OFF EQU 0EH
RETURN_HOME EQU 02H
MODE_SET EQU 06H
CLEAR_DIS EQU 01H
DDRAM_ADD EQU 80H
CNT EQU 40H
CNT1 EQU 41H
CNT2 EQU 42H
MOV SP,#50H
MOV PSW,#00H
MOV CNT2,#10H
MOV R0,#14H
MOV R1,#FFH
LCALL DELAY
MOV DPTR,#CNTRL
MOV A,#80H
MOVX @DPTR,A
LCALL SET_CON_LINES
BACK: MOV R2,#03H
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,#FUNCTION_SET
MOVX @DPTR,AMOV
DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
MOV R0,#06H
MOV R1,#E4H
LCALL DELAY
DJNZ R2,BACK
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,#DIS_ON_OFF
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOV DPTR,#PORTA
MOV A,#RETURN_HOME
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,#MODE_SET
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,#CLEAR_DIS
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
MOV CNT1,#02H
MOV CNT,#08H
MOV R0,#DDRAM_ADD
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOV DPTR,#PORTA
MOV A,R0
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
CLR A
MOV DPTR,#MSG
MOVX A,@DPTR
BACK3: MOV R1,A
INC DPTR
PUSH DPH
PUSH DPL
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#01H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,R1
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
POP DPL
POP DPH
CLR A
PUSH R0
PUSH R1
MOV R0,#7FH
MOV R1,#FFH
LCALL DELAY
POP R1
POP R0
DJNZ CNT,BACK3
DJNZ CNT1,F1
DJNZ CNT2,FORW1
LJMP FORW
MOV CNT,#08H
F1: PUSH DPH
PUSH DPL
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,#C0H
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
POP DPL
POP DPH
CLR A
LJMP BACK3
PUSH DPH
FORW1: PUSH DPL
MOV R0,#DDRAM_ADD
LCALL CHK_BUSY
LCALL SET_WR_CON_LINES
MOV A,#00H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOV A,R0
MOVX @DPTR,A
MOV DPTR,#CNTRL
MOV A,#05H
MOVX @DPTR,A
NOP
NOP
MOV A,#04H
MOVX @DPTR,A
MOV CNT,#08H
MOV CNT1,#02H
POP DPL
POP DPH
CLR A
LJMP BACK3
FORW : LCALL 0003H
SET_CON_LINES: MOV DPTR,#CNTRL
MOV A,#01H
MOVX @DPTR,A
MOV A,#03H
MOVX @DPTR,A
MOV A,#04H
MOVX @DPTR,A
RET
CHK_BUSY: MOV DPTR,#CNTRL
MOV A,#90H
MOVX @DPTR,A
MOV A,#04H
MOVX @DPTR,A
MOV A,#00H
MOVX @DPTR,A
MOV A,#03H
MOVX @DPTR,A
BACK2: MOV A,#05H
MOVX @DPTR,A
MOV DPTR,#PORTA
MOVX A,@DPTR
MOV B,A
MOV DPTR,#CNTRL
MOV A,#04H
MOVX @DPTR,A
MOV A,B
JNB A.7,F2
LJMP BACK2
F2: MOV DPTR,#CNTRL
MOV A,#80H
MOVX @DPTR,A
RET
SET_WR_CON_LINES: MOV DPTR,#CNTRL
MOV A,#04H
MOVX @DPTR,A
MOV A,#02H
MOVX @DPTR,A
DELAY: RET
LOOP1: PUSH R1
LOOP: NOP
DJNZ R1,LOOP
POP R1
DJNZ R0,LOOP1
RET
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT 16
INTERFACING MATRIX/KEYBOARD TO 8051
PROGRAM 16 (A): INTERFACING MATRIX/KEYBOARD TO 8051
TOOLS REQUIRED: 8051 Trainer kit, Keyboard Module and PC with installed Keil
µVision IDE - MDK plus.
THEORY: The key board here we are interfacing is a matrix keyboard. This key board
is designed with a particular rows and columns. These rows and columns are connected
to the microcontroller through its ports of the micro controller 8051. We normally use
8*8 matrix key board. So only two ports of 8051 can be easily connected to the rows and
columns of the key board.
Whenever a key is pressed, a row and a column gets shorted through that pressed
key and all the other keys are left open. When a key is pressed only a bit in the port goes
high. This indicates microcontroller that the key is pressed. By this high on the bit key
in the corresponding column is identified.
Once we are sure that one of key in the key board is pressed next our aim is to
identify that key. To do this we firstly check for particular row and then we check the
corresponding column the key board.
To check the row of the pressed key in the keyboard, one of the row is made high
by making one of bit in the output port of 8051 high. This is done until the row is found
out. Once we get the row next out job is to find out the column of the pressed key. The
column is detected by contents in the input ports with the help of a counter. The content
of the input port is rotated with carry until the carry bit is set.
The contents of the counter is then compared and displayed in the display. This
display is designed using a seven segment display and a BCD to seven segment decoder
IC 7447.
The BCD equivalent number of counter is sent through output part of 8051
displays the number of pressed key.
Keyboard is organized in a matrix of rows and columns as shown in the figure. The
microcontroller accesses both rows and columns through the port.
1. The 8051 has 4 I/O ports P0 to P3 each with 8 I/O pins, P0.0 to P0.7, P1.0 to P1.7, P2.0
to P2.7, P3.0 to P3.7. The one of the port P1 (it understood that P1 means P1.0 to P1.7)
as an I/P port for microcontroller 8051, port P0 as an O/P port of microcontroller 8051
and port P2 is used for displaying the number of pressed key.
2. Make all rows of port P0 high so that it gives high signal when key is pressed.
3. See if any key is pressed by scanning the port P1 by checking all columns for non zero
condition.
4. If any key is pressed, to identify which key is pressed make one row high at a time.
5. Initiate a counter to hold the count so that each key is counted.
6. Check port P1 for nonzero condition. If any nonzero number is there in [accumulator],
start column scanning by following step 9.
7. Otherwise make next row high in port P1.
8. Add a count of 08h to the counter to move to the next row by repeating steps from step
6.
9. If any key pressed is found, the [accumulator] content is rotated right through the carry
until carry bit sets, while doing this increment the count in the counter till carry is found.
10. Move the content in the counter to display in data field or to memory location
11. To repeat the procedures go to step 2.
FLOW CHART:
PROGRAM:
after identifying the row to check the colomn following steps are followed
OUTPUT:
RESULT:
VIVA QUESTIONS:
2. Define IVT.
4. What is MODEM?
EXPERIMENT 17
DATA TRANSFER FROM PERIPHERAL TO MEMORY THROUGH DMA
CONTROLLER 8237/8257
PROGRAM 17 (A): DATA TRANSFER FROM PERIPHERAL TO MEMORY THROUGH DMA
CONTROLLER 8237/8257
TOOLS REQUIRED: 8086 trainer kit with power adapter, DMA Controller 8257, PC
With installed Windows 7, DOSBOX and MASM.
THEORY: Interface DMA with 8086 so that the channel 0 DMA addresses reg.,TC reg.
and MSR has an I/O address 80 H, 81 H and 88 H . Initialize the 8257 with normal
priority, TC stop and non-extended write. Auto load is not required. Write an ALP to
move 2KB of data from peripheral device to memory address 2000 H: 5000 H, with the
above initialization. The transfer has to take place using channel 0.
MSR = 41 H
DMA address register = 5000 H
TC = 47FF H
FLOW CHART:
PROGRAM:
ASSSUME CS:CODE
ADDREG EQU 80 H
TC EQU 81 H
MSR EQU 88 H
CODE SEGMENT
START: MOV AX, 2000 H
MOV DS,AX
MOV AX,5000 H ; DMA ADDRESS REGISTER
OUT ADDREG, AL ; DMA ADDRESS REGISTER
OUT ADDREG, AH ; DMA ADDRESS REGISTER
MOV AX,47FF H ; TERMINAL COUNT REGISTER
OUT TC, AL ; TERMINAL COUNT REGISTER
OUT TC, AH ; TERMINAL COUNT REGISTER
MOV AL,41 H ; MODE SET REGISTER
OUT MSR, AL ; MODE SET REGISTER
HLT
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
2. Explain PROC?
ADDITIONAL EXPERIMENTS
EXPERIMENT-18
FINDING EVEN AND ODD NUMBERS IN AN GIVEN ARRAY
OBJECTIVE: To write an assembly language program to find the even and odd
numbers in an given array..
FLOW CHART:
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 56H, 49H, 33H
EVN DW 1 DUP (00)
ODD DW 1 DUP (00)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
XOR AX, AX
MOV SI, OFFSET N1
MOV DX, 0000H
MOV BX, 0000H
MOV CX, 0003H
BACK: MOV AL, [SI]
ROR AL, 01H
JC X
INC BX
JMP Y
X: INC DX
Y: INC SI
DEC CX
JNZ BACK
MOV EVN,BX
MOV ODD,DX
INT 3H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT-19
FINDING POSITIVE AND NEGATIVE NUMBERS IN AN GIVEN ARRAY
FLOW CHART:
PROGRAM:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
N1 DB 51H, 20H, 33H, 80H,19H
POSITIVE DW 1 DUP (00)
NEGATIVE DW 1 DUP (00)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
XOR AX, AX
MOV SI, OFFSET N1
MOV DX, 0000H
MOV BX, 0000H
MOV CX, 0005H
BACK: MOV AL, [SI]
ROL AL, 01H
JC X
INC BX
JMP Y
X: INC DX
Y: INC SI
DEC CX
JNZ BACK
MOV POSITIVE,BX
MOV NEGATIVE,DX
INT 3H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS:
EXPERIMENT-20
FINDING THE LARGSET AND SMALLEST NUMBERS IN AN GIVEN ARRAY
OBJECTIVE: To write an assembly language program to find the Largest and Smallest
numbers in an given array..
FLOW CHART:
PROGRAM:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
N1 DB 20H, 33H,08H,19H,77h
LARGEST DB 1 DUP(00)
SMALLEST DB 1 DUP(00)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
XOR AX, AX
MOV SI, OFFSET N1
MOV DX, 0000H
MOV BX, 0000H
MOV CX, 0004H
MOV AL, [SI]
BACK: CMP AL,[SI+1]
JG X
MOV AL,[SI+1]
X: INC SI
LOOP BACK
MOV LARGEST,AL
MOV CX,04H
MOV SI,OFFSET N1
MOV AL, [SI]
BACK1: CMP AL,[SI+1]
JL Y
MOV AL,[SI+1]
Y: INC SI
LOOP BACK1
MOV SMALLEST,AL
INT 3H
CODE ENDS
END START
OUTPUT:
RESULT:
VIVA QUESTIONS: