Vous êtes sur la page 1sur 68

INSTRUCTIONS TO THE STUDENTS

1.

Students are required to attend all labs.

2. Students will work in a group of two in hardware laboratories and individually in computer laboratories. 3. etc. While coming to the lab bring the lab manual cum observation book, record

4. Take only the lab manual, calculator (if needed) and a pen or pencil to the work area.

5.

Before coming to the lab, prepare the prelab questions. Read through the lab experiment to familiarize yourself with the components and assembly sequence. 6. Utilize 3 hours time properly to perform the experiment and noting down the readings. Do the calculations, draw the graph and take signature from the instructor. 7. If the experiment is not completed in the prescribed time, the pending work has to be done in the leisure hour or extended hours.

8.

You will be expected to submit the completed record book according to the deadlines set up by your instructor. 9. For practical subjects there shall be a continuous evaluation during the semester for 25 sessional marks and 50 end examination marks. 10. Of the 25 marks for internal, 15 marks shall be awarded for day-to-day work and 10 marks to be awarded by conducting an internal laboratory test.

TABLE OF CONTENTS
S.NO NAME OF THE EXERCISE PAGE NO

I. MICROPROCESSOR 8086 Experiment.1


1. Introduction to MASM/TASM 2. Using Turbo Assembler-Linker-Debugger (TASM,TLINK,TD) 5 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 38 40 43 47 48

Experiment.2
1. Multi Byte Addition 2. Multi Byte Subtraction 3. 8 Bit Multiplication (UNSIGNED) 4. 16 Bit Multiplication (UNSIGNED) 5. 8 Bit Division(UNSIGNED) 6. 16 Bit Division(UNSIGNED) 7. 8-Bit Multiplication (SIGNED) 8. 8-Bit Division (SIGNED) 9. ASCII Addition 10. ASCII Subtraction

Experiment.3
1.1.Sum of Digits of a given 16-Bit number 1.2 Check whether a given 16-Bit number is EVEN (or) ODD 1.3 Check whether a given 16-Bit number is Positive (or) Negative 2. Conversion of Packed BCD to Unpacked BCD 3. BCD to ASCII Conversion

Experiment.4
1. Sorting(ascending) 2. Sorting(descending) 3. Length of the String 4. String Comparison 5. Block transfer 6. String Insertion 7. Sting Deletion 8. String Reversal

Experiment.5
1. Reading keyboard with ECHO 2. Reading keyboard without ECHO 3. Displaying a character 4. Displaying a String

II.INTERFACING WITH 8086


1. 2. 3. 4. 8255 PPI INTERFACING 8279 KEYBOARD/DISPLAY INTERFACING 8259 PROGRAMMABLE INTERUPT CONTROLLER 8251 USART

III.8051 MICROCONTROLLER
1.1. 8-Bit & 16-Bit Addtion 1.2. Subtraction 1.3. Multiplication 1.4. Division 2. Data Transfer 3. Understanding Addressing Modes 4. Understanding the usage of LCALL Instruction 5. Understanding the usage of ACALL Instruction 6. Understanding three memory areas of 00-FF 51 53 54 55 56 57 59 60 61 63 65 67 68

IV.APPENDIX
1. Expected Questions from Microprocessors 2. Expected Questions from Microcontrollers 3. Key to the Questions on Microprocessors 4. Key to the Questions on Microcontrollers

1. INTRODUCTION TO 8086, MASM/TASM

This chapter is intended to serve as an introduction to the programming and some features of 8086 microprocessor. The users are requested to read 8086 architecture and organization of 8086 for better understanding. The 8086 programming model includes general purpose registers, segment registers, flag register, base and pointer registers whose functions are briefly given below

SEGMENT REGISTERS:
Code segment register CS stores the base address of code segment. Stack segment register SS stores the base address of the stack. Data segment register DS stores the base address of the data. Extra segment register ES stores the base address of the extra segment.

INDEX REGISTERS:
Source index register SI stores the base address of the source data. Destination index register DI stores the base address of the destination data.

POINTER REGISTERS:
Instruction pointer IP stores the address of next instruction. Stack pointer SP stores the address at the top of the stack. Base pointer BP stores the base address.

GENERAL PURPOSE REGISTERS:


Accumulator AX used in all arithmetic instructions. Base register BX used to store base addresses while programming. Counter register CX used as counter during programming. Destination register DX - used to store base addresses while programming. Extended accumulator DX: AX used in some arithmetic instructions. All these 16 bit registers can also be used as a pair of 2 8-bit registers.

FLAG REGISTER:
The flag register in 8086 is of 16 bit wide in which only 9 bits are used as flags and the other bits are in dont care condition. For complete flag format the users are requested to refer to the books, here only the functions of each flags are briefly given in order to be helpful while programming. A flag is a flip-flop, which is set or reset after an operation according to the data conditions of the result in the accumulator and other registers. 1. 2. 3. Zero flag Z: The flag is set to 1 when the result is zero, otherwise it is reset. Carry flag (barrow) CY: If an arithmetic operation results in a carry, the CY flag is set, otherwise it is reset. Sign flag S: The sign flag is set if the MSB bit of the result is one, otherwise it is reset. Parity flag P : If the result has an even number of 1s, the flag is set, for odd number of 1s the flag is reset. Direction flag D: This flag selects increment or decrement mode for the DI and/or SI registers during string instructions. If D=1, the registers are

4.
5.

6. 7. 8. 9.

automatically decremented; if D=0, the registers are automatically incremented. Overflow flag O: Overflow occurs when signed numbers are added or subtracted. An overflow indicates that the result has exceeded the capacity of the machine. Trap flag T: The trap flag enables trapping through an on chip debugging feature. Interrupt flag I: The interrupt flag controls the operation of INTR input pin. If I=1 INTR is enabled otherwise it is disabled. Auxiliary carry flag AC: The auxiliary carry holds the carry( half carry) after addition or barrow after subtraction between bit positions 3 and 4 of the result. This bit is tested in special instructions like DAA and DAS.

INSTRUCTION SET OF 8086


An instruction is a command to the microprocessor to perform a given task on specified data. Each instruction has two parts: one is task to be performed, called the operation code (opcode) and the second is the data to be operated on, called the operand. The entire group of instructions, called the instruction set, determines what function the microprocessor can perform. The 8086 instructions can be classified into following categories depending on their functions.

DATA TRANSFER INSTRUCTIONS:


This group of instructions copies the data from a location called source to another location called destination, without modifying the contents of the source. The one more specialty of this group is they will not effect any of the flags in the flag register. The data transfer may be between registers, memory location and a register, immediate data and memory or register and between I/O device and the accumulator.

ARITHMETIC INSTRUCTIONS:
These instructions perform arithmetic operations such as addition, subtraction, increment and decrement. The flags are affected by this group of instructions depending on the results they produce but some special instructions will not effect flags.

LOGICAL, SHIFT OR ROTATE INSTRUCTIONS:


These instructions perform various logical operations such as AND, OR, NOT, compare etc. These instructions will also effect flags.

BRANCHING INSTRUCTIONS:
This group of instructions alters the sequence of program execution either conditionally or unconditionally. Flags are generally used to generate conditions in case of 1st type of branch instructions.

MACHINE CONTROL INSTRUCTIONS:

These instructions control machine functions such as halt, interrupt and do nothing etc.

FLAG MANIPULATION INSTRUCTIONS: These instructions perform various operations on flags such as clearing carry flag, set carry flag etc. STRING INSTRUCTIONS:

These instructions special and serve the purpose of operations on strings.

MASM/TASM
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 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 the disk, where you saved it after editing on the first pass through the source program the assembler determines the displacement of named data items, the offset of labels and puts this information in 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 is 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 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 to an exe file. The linker produces a link file, which contains the binary codes for all the combined modules. The linker however doesnt assign absolute addresses to the program, it assigns is said to be relocatable because it can be put anywhere in memory to be run. In MASM, MLINK 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 are 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, the filename is used to debug the file.

DEBUGGER FUNCTIONS:
1. Debugger allows to look at the contents of registers and memory locations. 2. We can extend 8-bit register to 16-bit register which the help of extended register option. 3. Debugger allows setting breakpoints at any point with the program.

4. The debugger will run the program up to the instruction where the breakpoint is set and then stop execution of program. At this point, we can examine registry and memory contents at that point.

COMMANDS TO EXECUTE A GIVEN ALP.


1. ASSMEBLINIG 2. LINKING 3. DEBUGGING : : : masm <file name.asm> <Enter> link <file name.obj> <Enter> debug <file name.exe> <Enter>

DEBUGGER COMMANDS
DUMP: To see the specified memory contents D memory location first address last address (While displays the set of values stored in the specified range, which is given above) Eg: d 0100 0105 <cr> Display the contents of memory locations from 100 to 105(including). ENTER: To enter data into the specified memory locations(s). E memory location data data data data data <cr> Eg: e 1200 10 20 30 40 . Enters the above values starting from memory locations 1200 to 1203, by loading 10 into 1200,20 into 1201 and soon. GO: To execute the program G address <cr>: executes from current IP to the address specified G first address last addresses <cr>: executes a set of instructions specified between the given addresses. QUIT: To exit from the debugger. Q <cr> REGISTER: Shows the contents of Registers R register name Eg: r ax Shows the contents of register. TRACE: To trace the program instruction by instruction. T = 0100 <cr>: traces only the current instruction. (Instruction specified by IP) T = 0100 02 <cr>: Traces instructions from 100 to 101, here the second argument specifies the number of instructions to be traced. UNASSEMBLE: To unassembled the program. Shows the opcodes along with the assembly language program. U 100 <cr>: unassembled 32 instructions starting from 100th location. U 0100 0109 <cr>: unassebles the lines from 100 to 104

2.Using Turbo Assembler Linker Debugger (TASM, TLINK, TD)

1. Open an MSDOS window. 2. Set the PATH so that the TASM programs are available The TASM programs are on the C drive; set the path so that DOS can find them. This only needs to be done once each time you open an MSDOS prompt. Set PATH=%PATH%;C:\TASM\BIN 3. Use a Text Editor to Edit the .ASM File. Create your file using one of the following programs: notepad proj.asm wordpad proj.asm edit proj.asm 4. Compile the source code to create an object module. tasm/z/zi proj.asm The /z switch causes TASM to display the lines that generate compilation errors. The /zi switch enables information needed by the debugger to be included in the .OBJ file. Note that you should use "real mode" assembler, TASM.EXE. Do not use the "protected mode" assembler TASM32.EXE for the assignments that will be given in class 5. Run Linker TLINK.EXE- generate .EXE file from the .OBJ file tlink/v proj 6. Run the Program Your final program (if there were no errors in the previous step) will have an .EXE ending. To just run it, type: proj If you want to use the debugger to examine the instructions, registers, etc., type: td proj This brings up the regular full-screen version of the Turbo debugger. 1. Tracing the Program's Execution The Turbo debugger first starts, a Module Window which displays the . Executable lines of program code, marked with a bullet in the left column of the window. You can set breakpoints or step to any of these lines of code. An arrow in the first column of the window indicates the location of the instruction pointer. This always points to the next statement to be executed. To execute just that instruction use one of the two methods listed under the Run menu item: o Trace into (can use F7 key): executes one instruction; traces "into" procedures. o Step over (can use F8 key): executes one instruction; skips (does not trace into) procedures.Hitting either of these executes the instruction, and moves the arrow to the next instruction. As eachinstruction executes, the effects might be visible in the Registers Window and Watches Window Trace into (can use F7 key): executes one instruction; traces "into" procedures. o Step over (can use F8 key): executes one instruction; skips (does not trace into) procedures. Hitting either of these executes the instruction, and moves the arrow to the next instruction. As each instruction executes, the effects might be visible in the Registers Window and Watches Window 2. Setting and Removing Breakpoints

To set a breakpoint, position the cursor on the desired line of source code and press F2. The line containing the breakpoint will turn red. Pressing F2 again removes the breakpoint. To execute all instructions from the current instruction pointer up to the next encountered breakpoint, choose Run (can use F9 key) from the Run menu item. 3. Examining Registers Another window, the Registers Window, can be opened to examine the current value of the CPU registers and flags. The View menu can be used to open this Registers Window. The registers and flags might change as each instruction is executed. 4. Examining Memory To examine memory, you will need to open an Inspector window. An Inspector window shows the contents of a data structure (or simple variable) in the program you are debugging. It also allows you to modify the contents of the data structure or variable. To open an Inspector window, place the cursor on what you want to inspect and press CTRL I.After you've examined the data item, press the ESC key to remove the Inspector window. 5. Viewing the Program's Output Output written to the screen by a program is not immediately visible, since the main purpose of using a debugger is to examine the internal operation of the program. To observe what the user would see, press ALT - F5. The entire screen will change to a userview showing the program's input and output (and possibly that of previous programs as well). Press any key to return to the debugger screen.

2.1 MULTI BYTE ADDITION

AIM:

To write a program to add two multi byte numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DD 11223344H NUM2 DD 55667788H RES DD 00000000H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV SI,OFFSET NUM1 MOV DI,OFFSET NUM2 MOV BX,OFFSET RES MOV CX,03 SUB AX,AX MOV AL,[SI] MOV DL,[DI] ADD AL,DL MOV [BX],AL BACK: INC SI INC DI INC BX MOV AL,[SI] MOV DL,[DI] ADC AL,DL MOV [BX],AL LOOP BACK INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: RES=

RESULT:
Multi byte addition is performed and results are observed using TASM.

EXERCISE:
1. 2. 3. 4. Why is add with carry instruction adc is used in the loop? What is the purpose served by BX register? Why addition is done with AL register why not with AX? What is the other instruction which is useful instead of MOV SI,offset num1?

2.2 MULTI BYTE SUBTRACTION

AIM:

To write a program to subtract two multi byte numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM2 DD 55667788H NUM1 DD 11223344H RES DD 00000000H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV SI,OFFSET NUM2 MOV DI,OFFSET NUM1 MOV BX,OFFSET RES MOV CX,03 SUB AX,AX MOV AL,[SI] MOV DL,[DI] SUB AL,DL MOV [BX],AL BACK: INC SI INC DI INC BX MOV AL,[SI] MOV DL,[DI] SBB AL,DL MOV [BX],AL LOOP BACK INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: RES=

RESULT:
Multi byte subtraction is performed and results are observed using TASM

EXERCISE:
1. 2. 3. 4. Why is subtract with carry instruction is used in the loop? What is the purpose served by BX register? Why subtraction is done with AL register why not with AX? What is the other instruction which is useful instead of MOV DI, offset NUM2?

2.3 8 BIT MULTIPLICATION (UNSIGNED)

AIM:

To write a program to multiply two 8-bit unsigned numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DB 0FFH NUM2 DB 0AAH RESULT DB 00 RESULT1 DB 00 DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AL, NUM1 MOV BL, NUM2 MUL BL MOV RESULT, AL MOV RESULT1, AH INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: NUM1= NUM2= RES= RES1=

RESULT:
8-bit unsigned multiplication is performed and results are observed using TASM.

EXERCISE:

1. AL and BL are used for multiplying why not AX & BX? 2. Instead of using MOV BL is it not possible to MUL num2? 3. What is the instruction used for signed multiplication?

2.4 16 BIT MULTIPLICATION (UNSIGNED)

AIM:

To write a program to multiply two 16-bit unsigned numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DW 0FFFFH NUM2 DW 0FFFFH RESULT DW 00 RESULT1 DW 00 DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX,DATA MOV DS,AX MOV AX,NUM1 MOV BX,NUM2 MUL BX MOV RESULT,AX MOV RESULT1,DX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: NUM1= NUM2= RESULT= RESULT1=

RESULT:
16-bit Multiplication is performed and results are observed using TASM.

EXERCISE:

1. Why AL & BL are not used in this program? 2. If result exceeds 32 bit, where is it stored?

2.5 8 BIT DIVISION(UNSIGNED)

AIM:

To write a program to perform division on two 8-bit unsigned numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DB 0FFH NUM2 DB 0AAH QUOTIENT DB 00 REMAINDER DB 00 DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX,DATA MOV DS,AX MOV AX,0 MOV DX,0 MOV AL,NUM1 MOV BL,NUM2 DIV BL MOV QUOTIENT,AL MOV REMAINDER,AH INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: QUOTIENT= REMAINDER=

RESULT:
Division of two 8-bit numbers is performed and results are observed using TASM.

EXERCISE:
1. 2. 3. 4.

Why is the registers DX & AX made zero in the above program? Where is the remainder in 8 bit division? Where is the quotient in 8 bit division? Which interrupt is used when a divide overflow error occurs?

2.6 16 BIT DIVISION(UNSIGNED)

AIM:

To write a program to perform division on two 16-bit unsigned numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DW 0FFFFH NUM2 DW 0AAAAH QUOTIENT DW 00 REMAINDER DW 00 DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX,DATA MOV DS,AX MOV AX,0 MOV DX,0 MOV AX,NUM1 MOV BX,NUM2 DIV BX MOV QUOTIENT,AX MOV REMAINDER,DX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: QUOTIENT= REMAINDER=

RESULT:
16-bit division is performed and results are observed using TASM.

EXERCISE:
1. What happens if DX register contains a nonzero value before DIV instruction? 2. What is the instruction used for signed division? 3. In the above program instead of DIV BX is it possible to use DIV num2?

2.7 8-BIT MULTIPLICATION (SIGNED)

AIM:

To write a program to multiply two 8-bit signed numbers. Computer system installed with TASM

APPARATUS: PROGRAM:
DATA SEGMENT NUM1 DB NUM2 DB RES DW DATA ENDS

0A5H 20H 00H

CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX SUB AX,AX MOV AL,NUM1 MOV BL,NUM2 IMUL BL MOV RES,AX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: RES=

RESULT:
TASM. 8-bit signed multiplication is performed and results are observed using

EXERCISE:

1. What is the difference between IMUL and MUL? 2. What is the use of instruction CBW? 3. What is the use of instruction CWD?

2.8 8-BIT DIVISION (SIGNED)

AIM:

To write a program to perform division on two 8-bit signed numbers. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT NUM1 DB 0D5H NUM2 DB 20H QUO DB 0H REM DB 0H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX XOR AX,AX MOV AL,NUM1 CBW MOV BL,NUM2 IDIV BL MOV QUO,AL MOV REM,AH INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: QUO= REM=

RESULT:

8-bit signed division is performed and results are observed using TASM.

EXERCISE:
1. What is the purpose of XOR AX,AX? 2. What is the difference between IDIV and DIV? 3. What is the use of instruction CBW & CWD?

2.9 ASCII ADDITION

AIM:

To write a program to perform ASCII addition. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT IP1 DB '9',0DH,0AH IP2 DB '6',0DH,0AH RES DB 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX XOR AX,AX MOV AL,IP1 ADD AL,IP2 AAA MOV RES,AL MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: IP1= IP2= OUTPUT: RES=

RESULT:
ASCII addition is performed and results are observed using TASM.

EXERCISE:
1. 2. 3. 4.

What is the purpose of ASCII addition? What is the instruction used for ASCII addition? Why do we make use of instruction ORL AX,3030H ? Why is aaa after addition?

2.10 ASCII SUBTRACTION

AIM:

To write a program to perform ASCII subtraction. Computer system installed with TASM

APPARATUS: PROGRAM:

DATA SEGMENT IP1 DB '9',0DH,0AH IP2 DB '6',0DH,0AH RES DB 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX XOR AX,AX MOV AL,IP1 SUB AL,IP2 AAS MOV RES,AL MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: IP1= IP2= OUTPUT: RES=

RESULT:
ASCII subtraction is performed and results are observed using TASM.

EXERCISE:
1. 2. 3. 4.

What is the purpose of ASCII subtraction? What is the instruction used for ASCII subtraction? Why do we make use of instruction ORL AX,3030H ? Why is aas after addition?

3.1.1 SUM OF DIGITS OF A GIVEN 16-BIT NUMBER

AIM:

To write a program to find the sum of digits of a given 16-bit number 16Bit number should be given at ds:2000, and result will be available at ds:3000h.

APPARATUS: PROGRAM:
CODE SEGMENT

Computer system installed with TASM

ASSUME CS:CODE START: MOV AX,DS:2000H MOV SI,0010H MOV DX,0000H MOV BX,0 MOV CX,0004H NEXT:DIV SI ADD BX,DX MOV DX,0000H LOOP NEXT MOV DS:3000H,BX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: DS:2000H = DS:3000H =

RESULT:
Sum of digits of a given 16-bit number is performed and results are observed using TASM.

EXERCISE:

1.What is the logic used to find sum of digits of a given number? 2.What a LOOP instruction would do in the above program?

3.1.2 CHECK WHETHER A GIVEN 16-BIT NUMBER IS EVEN OR ODD

AIM:
odd.

To write a program to check whether a given 16-bit number is even or

Note: 16-Bit number should be given at ds:2000, and result will be available at ds:3000h. If the number is even, store ffffh at ds:3000h, and if it is odd, store 1111h at ds:3000H

APPARATUS: PROGRAM:
CODE SEGMENT

Computer system installed with TASM

ASSUME CS:CODE START: MOV AX,DS:2000H MOV BX,0002H MOV CX,0000H DIV BX CMP DX,CX JE EVEN_NUM MOV DS:3000H,1111H JMP EXIT EVEN_ NUM:MOV DS:3000H,0FFFFH EXIT:INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: DS:2000H = DS:3000H =

RESULT:
Checking whether a given 16-bit number is even or odd is performed and results are observed using TASM.

EXERCISE:
1.How can we differentiate between an even number and an odd number?

3.1.3 CHECK WHETHER A GIVEN 16-BIT NUMBER IS POSITIVE OR NEGATIVE

AIM:

To write a program to check whether a given 16-bit number is positive or negative. Note: 16-Bit number should be given at ds:2000, and result will be available at ds:3000h. If the number is positive, store ffffh at ds:3000h, and if it is negative,store 1111h at ds:3000h

APPARATUS: PROGRAM:
CODE SEGMENT

Computer system installed with TASM

ASSUME CS:CODE START: MOV AX,DS:2000H ROL AX,1 JC NEG_NUM MOV DS:3000H,0FFFFH JMP EXIT NEG_NUM:MOV DS:3000H,1111H EXIT:INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: DS:2000H = DS:3000H =

RESULT:
Checking whether a given 16-bit number is positive or negative is performed and results are observed using TASM.

EXERCISE:

1.How can we differentiate between a positive number and a negative number?

3.2 PACKED TO UNPACKED BCD


AIM:
To write a program to convert a packed BCD number to unpacked BCD number.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT BCDIP DB 56H UBCDOP DW 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX XOR AX,AX MOV AL, BCDIP MOV DL,AL AND AL,0F0H MOV CL,4 ROR AL,CL MOV BH,AL AND DL,0FH MOV BL,DL MOV UBCDOP,BX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: BCDIP= UBCDOP=

RESULT:
Conversion of packed BCD to unpacked BCD is performed and results are observed using TASM.

EXERCISE:
1. What is the purpose of the instruction ROR AL, CL? 2. What is the purpose of the instruction AND AL, 0FH & AND AL,0F0H in the program? 3. What is the expansion of UPBCD? 4. What is the use of DAA instruction? 5. What is the reason for packing unpacked BCD? 6. What is common between unpacked BCD and ASCII?

3.3 BCD to ASCII CONVERSION


AIM:
To write a program to convert a BCD number to its equivalent ASCII number.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT BCDIP DB 56H ASCOP DW 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX XOR AX,AX MOV AL, BCDIP MOV DL,AL AND AL,0F0H MOV CL,4 ROR AL,CL MOV BH,AL AND DL,0FH MOV BL,DL ADD BX,3030H MOV ASCOP,BX INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: BCDIP= ASCOP=

RESULT:
Conversion of BCD to ASCII is performed and results are observed using TASM.

EXERCISE:

1. What is the difference between adding 30h and OR 30H to a BCD number to conversion to ASCII? 2. Why unpacking is necessary during the conversion? 3. What is the ASCII character for symbol A? 4. What is the ASCII character for symbol zero 0?

4.1 SORTING(ASCENDING)
AIM:
To write a program to sort a given list of numbers in ascending order.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT LIST DB 12H, 34H, 21H, 56H, 32H COUNT EQU 5 DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX, DATA MOV DS, AX MOV DI, OFFSET LIST MOV CL, COUNT DEC CL INC DI LOOP1:MOV DL,CL LOOP2:MOV AL,[DI] CMP AL,[DI +1] JNC Proceed XCHG AL,[DI+1] MOV [DI],AL PROCEED: INC DI LOOP LOOP2 NOP MOV CL,DL LOOP LOOP1 INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: LIST: LIST(SORTED):

RESULT:
Sorting of a given list of numbers is performed and results are observed using TASM.

EXERCISE:
1.What is the sorting technique used in above program? 2.Are there any other ways to sort a list?

4.2 SORTING(DESCENDING)
AIM:
To write a program to sort a given list of numbers in descending order.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT LIST DB 12H, 34H, 21H, 56H, 32H COUNT EQU 5 DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX, DATA MOV DS, AX MOV DI, OFFSET LIST MOV CL, COUNT DEC CL INC DI LOOP1:MOV DL,CL LOOP2:MOV AL,[DI] CMP AL,[DI +1] JC Proceed XCHG AL,[DI+1] MOV [DI],AL PROCEED: INC DI LOOP LOOP2 NOP MOV CL,DL LOOP LOOP1 INT 3 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: LIST: LIST(SORTED):

RESULT:
Sorting of a given list of numbers is performed and results are observed using TASM.

EXERCISE:
1.What is the sorting technique used in above program? 2.Are there any other ways to sort a list?

4.3 LENGTH OF THE STRING


AIM:
To write a program to find the length of the given string.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT STRING1 DB 'EMPTY VESSELS MAKE MORE NOISE$' STRLEN EQU ($-STRING1) RES DB 0 CORT DB 'STRLENGTH FOUND CORRECT$' INCORT DB 'STRLENGTH FOUND INCORRECT$' DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX SUB CL,CL MOV BL,STRLEN MOV SI,OFFSET STRING1 BACK: LODSB INC CL CMP AL,'$' JNZ BACK MOV RES,CL CMP CL,BL JZ CORRECT MOV DX,OFFSET INCORT MOV AH,09 INT 21H CORRECT:MOV DX,OFFSET CORT MOV AH,09 INT 21H MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: STRING1= STRLEN= OUTPUT: RES=

RESULT:
Length of a string is performed and results are observed using TASM.

EXERCISE:

1. What is the operation performed by the instruction cmp al,$ ? 2. What is function 09h / int 21h performed? 3. Why SI is not been incremented is the program?

4.4 STRING COMPARISION


AIM:
To write a program to compare two strings. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT STRING1 DB 'EMPTY' STRLEN EQU ($-STRING1) NOTSFUL DB 'STRINGS ARE UNEQUAL$' SFUL DB 'STRINGS ARE EQUAL$' DATA ENDS EXTRA SEGMENT STRING2 DB 'EMPTY' EXTRA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:EXTRA START: MOV AX,DATA MOV DS,AX MOV AX,EXTRA MOV ES,AX MOV SI,OFFSET STRING1 MOV DI,OFFSET STRING2 CLD ;MOV CX,LENGTH STRING1 MOV CX,STRLEN REP CMPSB JZ 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 CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: STRING1 = STRING2 = STRLEN =

RESULT:
String comparison is performed and results are observed using TASM.

EXERCISE:

1. What is the significance of CLD? 2. How does CMPSB perform the comparison?

4.5 BLOCK TRANSFER

AIM:

To write a program to transfer a block of characters from one place to another place using string instructions.

APPARATUS: PROGRAM:

Computer system installed with TASM

DATA SEGMENT SRC DB 'EMPTY VESSELS MAKE MUCH NOISE',24H DATA ENDS EXTRA SEGMENT DST DB 12 DUP(0) EXTRA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:EXTRA START: MOV AX,DATA MOV DS,AX MOV AX,EXTRA MOV ES,AX MOV SI,OFFSET SRC MOV DI,OFFSET DST CLD MOV CX,29 REP MOVSB NOP MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: SRC= DST=

RESULT:
Block transfer is performed and results are observed using TASM.

EXERCISE:
1. If the DF=1, will the SI and DI register decremented? 2. The destination memory is pointed by which register combination? 3. The source is pointed to by which register combination?

4.6 STRING INSERTION


AIM:
To write a program to insert a word in the given sentence. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT STRING1 DB 'EMPTY VESSELS MORE NOISE$' STRLEN EQU ($-STRING1) DATA ENDS EXTRA SEGMENT STRING2 DB STRLEN+5 DUP(0) EXTRA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:EXTRA START: MOV AX,DATA MOV DS,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 NOP MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: NUM1= NUM2= OUTPUT: RES=

RESULT:
String insertion is performed and results are observed using TASM.

EXERCISE:

1. Why register DI is loaded with 5? 2. What is the function of rep movsb? 3. What is the purpose of mov ah,01h / int 21h?

4.7 STRING DELETION


AIM:
To delete a word from the given sentence. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT STRING1 STRLEN DATA ENDS DB EQU 'EMPTY VESSELS MAKE MORE NOISE$' ($-STRING1)

EXTRA SEGMENT STRING2 DB STRLEN-5 DUP(0) EXTRA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:EXTRA START: MOV AX,DATA MOV DS,AX MOV AX,EXTRA MOV ES,AX MOV SI,OFFSET STRING1 MOV DI,OFFSET STRING2 CLD MOV CX,13 REP MOVSB CLD MOV SI,18 MOV CX,12 REP MOVSB MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: STRING1= STRLEN= OUTPUT: STRING2=

RESULT:
String deletion is performed and results are observed using TASM.

EXERCISE:
1. What is the purpose of string length? 2. What does equ stands for? 3. What is the purpose of label start after the end directive?

4.8 STRING REVERSAL


AIM:
To write a program to reverse a given string. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT STRING1 DB 'EMPTY' STRLEN EQU ($-STRING1) STRING2 DB 5 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:DATA START: MOV AX,DATA MOV DS,AX MOV ES,AX MOV BX,OFFSET STRING1 MOV SI,BX MOV DI,OFFSET STRING2 ADD DI,STRLEN CLD MOV CX,STRLEN A1: MOV AL,[SI] MOV ES:[DI],AL INC SI DEC DI LOOP A1 ;REP MOVSB ;NOP MOV AH,4CH INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT: STRING1= STRLEN= STRING2=

RESULT:
String reversal is performed and results are observed using TASM.

EXERCISE:

1. Why BX register is added with 5? 2. Why MOVS instruction is not used? 3. What is the function of LODS and STOS instructions?

5.1 READING KEYBOARD WITH ECHO


AIM:
To write a program to read the keyboard with echo. Computer system installed with TASM

APPARATUS:

PROGRAM: DATA SEGMENT CHAR DB 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX,DATA MOV DS,AX MOV AH,01H INT 21H MOV CHAR, AL INT 3 CODE ENDS END START OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Reading a keyboard is performed and results are observed using TASM.

EXERCISE:
1.Write a brief note on DOS interrupts. 2.What does AH register hold when INT 21H is called?

5.2 READING KEYBOARD WITHOUT ECHO


AIM:
To write a program to read the keyboard without echo. Computer system installed with TASM

APPARATUS:

PROGRAM: DATA SEGMENT CHAR DB 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX,DATA MOV DS,AX MOV AH,08H INT 21H MOV CHAR, AL INT 3 CODE ENDS END START OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Reading a keyboard is performed and results are observed using TASM.

EXERCISE:

1.Write a brief note on DOS interrupts.


2.What does AH register hold when INT 21H is called?

5.3 DISPLAYING A CHARACTER


AIM:
To write a program to displaying a given string. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT CHAR DATA ENDS

DB

CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AH, 02H MOV DL,CHAR INT 21H MOV AX, 4C00H INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Displaying a character on screen is performed and results are observed using TASM.

EXERCISE:
1.Write a brief note on DOS interrupts. 2.What does AH register hold when INT 21H is called?

5.4 DISPLAYING A STRING


AIM:
To write a program to displaying a given string. Computer system installed with TASM

APPARATUS:

PROGRAM:
DATA SEGMENT MESSAGE DB 10, 13,HAPPY NEW YEAR, 10, 13,$ DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV DX, OFFSET MESSAGE MOV AH, 09H INT 21H MOV AX, 4C00H INT 21H CODE ENDS END START

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Displaying a string on screen is performed and results are observed using TASM.

EXERCISE: 1.Write a brief note on DOS interrupts.

2.What does AH register hold when INT 21H is called?

1. 8255 PPI INTERFACING -1


AIM: configure 8255A such that port A and port B as an output ports .Execute
the program at 0000:2000h

APPARATUS:

1. 8086 TRAINER KIT 2. 8255 STUDY CARD 3. ADAPTER, KEYBOARD, CABLES, ETC PROGRAM:
ADDRESS 0000:2000 8255 0000:2003 0000:2005 0000:2006 0000:2008 0000:200B 0000:200C AND 0000:200E 0000:2011 0000:2012 0000:2015 0000:2017 0000:2019 BA 42 FF EE B9 00 00 E2 FE E2 FE E9 EC FF MOVW DX, 0FF42 MOVW CX, 0 LOOP 2015 LOOP 2017 JMP RPT (2008) ; INTRODUCE DELAY ; AND REPEAT ; OUTPUT THIS OUTB DX, AL ; VALUE AT PORT B B0 80 EE B0 55 BA 40 FF EE F6 D0 RPT: MOVB AL, 80 ; PORTS AS O/P OUTB DX, AL MOVB AL, 55 ; OUTPUT DATA AT MOVW DX, 0FF40 OUTB DX, AL NOTB AL ; INVERT THE DATA ; PORT A OP-CODES BA 46 FF LABELS MNEMONICS COMMENTS MOVW DX, 0FF46 ; INITIALIZE

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8255 is done and results are observed.

8255 PPI INTERFACING -2


AIM: Configure 8255A such that port A as an output and port B as an input.
Execute the program at 0000:2000h.

APPARATUS:

PROGRAM:
ADDRESS 0000:2000 8255 0000:2003 0000:2005 0000:2006 FROM 0000:2009 0000:200A DATA 0000:200C THIS 0000:200F 0000:2010 PROCESS

1. 8086 TRAINER KIT 2. 8255 STUDY CARD 3. ADAPTER, KEYBOARD, CABLES, ETC

OP-CODES BA 46 FF B0 82 EE BA 42 FF EC F6 D0 BA 40 FF EE E9 F5 FF

LABELS

MNEMONICS COMMENTS MOVW DX, 0FF46 ; INITIALIZE

MOVB AL, 82 ; PORT A AS OUTPUT OUTB DX, AL ; PORT B AS INPUT RPT: MOVW DX, 0FF42 INB AL, DX NOTB AL MOVW DX, 0FF40 ; READ VALUE

; PORT B ; INVERT THE ; AND OUTPUT

OUTB DX, AL ; VALUE AT PORT A JMP RPT(2006) ; REPEAT

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8255 is done and results are observed.

8255 PPI INTERFACING -3


AIM: Configure 8255A such that port A as an input and port B as an output.
Execute the program at 0000:2000H.

APPARATUS:

PROGRAM:
ADDRESS 0000:2000 8255 0000:2003 0000:2005 0000:2006 FROM 0000:2009 0000:200A SAME 0000:200D 0000:200E PROCESS

1. 8086 TRAINER KIT 2. 8255 STUDY CARD 3. ADAPTER, KEYBOARD, CABLES, ETC

OP-CODES BA 46 FF B0 90 EE BA 40 FF EC BA 42 FF EE E9 F5 FF

LABELS

MNEMONICS COMMENTS MOVW DX, 0FF46 ; INITIALIZE

MOVB AL, 90 ; PORT B AS OUTPUT OUTB DX, AL ; PORT A AS INPUT RPT: MOVW DX, 0FF40 INB AL, DX ; READ VALUE

; PORT A ; OUTPUT THE

MOVW DX, 0FF42

OUTB DX, AL ; VALUE AT PORT B JMP RPT (2006) ; REPEAT

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8255 is done and results are observed.

EXERCISE for 8255: 1. Why we are calling it as PPI? 2.What is the drawback of 8255? 3.How many command words & mode words in this device? 4.How many ports & groups in 8255?

2. 8279 KEYBOARD/DISPLAY INTERFACING -1


AIM: To interface keyboard/display with 8086 microprocessor and display a given sentence on the display board.(Left Entry) APPARATUS: 1. 8086 TRAINER KIT

2. 8279 STUDY CARD 3. ADAPTER, KEYBOARD, CABLES, ETC


PROGRAM:

CMDREG DATAREG .8086 .MODEL TINY .STACK 32 .DATA .CODE

EQU EQU

0FFEBH 0FFE9H

ORG 2000H START: MOV AX,CS MOV DS,AX MOV AL,10H ; ENCODED SCAN-8CHAR 8 BIT LEFT ENTRY MOV DX,CMDREG OUT DX,AL MOV AL,090H ;WRITE RAM AUTO INCREMENT OUT DX,AL MOV CX,08 CLEAR:MOV AL,00 MOV DX,DATAREG OUT DX,AL LOOP CLEAR BACK: MOV DX,CMDREG IN AL,DX ; READ THE COMMAND R4EGISTER TO GET THE 8279 STATUS AND AL,07 ; NUMBER OF KEYS PRESSED IS IN THE LOWER 3 BITS MASK ;THESE AND CHECK IF NOT ZERO. IF ZERO NO KEY PRESSED JZ BACK MOV BX,OFFSET SSCHARLUT MOV AL,040H ; READ THE FIRST RAM ADDRESS OF FIFO OUT DX,AL MOV DX,DATAREG ; IN AL, DX AND AL,01FH XLAT ; CONVERT THE KEY READ TO THE SS CODE MOV DX,DATAREG OUT DX,AL ; DISPLAY AT THE CURRENT DIGIT POSITION JMP BACK SSCHARLUT: SS0 DB 3FH ;0 SS1 DB 6H ;1 SS2 DB 5BH ;2 SS3 DB 4FH ;3 SS4 DB 66H ;4 SS5 DB 6DH ;5 SS6 DB 7DH ;6 SS7 DB 07H ;7 SS8 DB 7FH

SS9 DB 6FH SSA DB 77H SSB DB 7CH SSC DB 39H SSD DB 5EH SSE DB 79H SSF DB 71H END START

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8279 is done and results are observed.

8279 KEYBOARD/DISPLAY INTERFACING -2


AIM: To interface keyboard/display with 8086 microprocessor and display a given sentence on the display board.(Right Entry) APPARATUS:

4. 8086 TRAINER KIT 5. 8279 STUDY CARD 6. ADAPTER, KEYBOARD, CABLES, ETC

PROGRAM:
CMDREG EQU 0FFEBH DATAREG EQU 0FFE9H .8086 .MODEL TINY .STACK 32 .DATA .CODE ORG 2000H START: MOV AX,CS MOV DS,AX MOV AL,0H ; ENCODED SCAN-8CHAR 8 BIT LEFT ENTRY MOV DX,CMDREG OUT DX,AL MOV AL,090H ;WRITE RAM AUTO INCREMENT OUT DX,AL MOV CX,08 CLEAR: MOV AL,00 MOV DX,DATAREG OUT DX,AL LOOP CLEAR BACK: MOV DX,CMDREG IN AL,DX ; READ THE COMMAND R4EGISTER TO GET THE 8279 STATUS AND AL,07 ; NUMBER OF KEYS PRESSED IS IN THE LOWER 3 BITS MASK ;THESE AND CHECK IF NOT ZERO. IF ZERO NO KEY PRESSED JZ BACK MOV BX,OFFSET SSCHARLUT MOV AL,040H ; READ THE FIRST RAM ADDRESS OF FIFO OUT DX,AL MOV DX,DATAREG IN AL, DX AND AL,01FH XLAT ; CONVERT THE KEY READ TO THE SS CODE MOV DX,DATAREG OUT DX,AL ; DISPLAY AT THE CURRENT DIGIT POSITION JMP BACK SSCHARLUT: SS0 DB 3FH ;0 SS1 DB 6H ;1 SS2 DB 5BH ;2 SS3 DB 4FH ;3 SS4 DB 66H ;4 SS5 DB 6DH ;5 SS6 DB 7DH ;6 SS7 DB 07H ;7 SS8 DB 7FH SS9 DB 6FH

SSA DB 77H SSB DB 7CH SSC DB 39H SSD DB 5EH SSE DB 79H SSF DB 71H END START

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8279 is done and results are observed.

EXERCISE for 8279:


1. 2. 3. 4. 5. How many pins does 8279 IC have? How many scan lines are available on 8279? How many row-sense pins are there on 8279? How many registers are there in 8279? What is the purpose of command & data registers?

3. 8259 PROGRAMMABLE INTERUPT CONTROLLER


AIM: To interface Programmable Interrupt Controller with 8086 microprocessor. APPARATUS: 1. 8086 TRAINER KIT

2. 8259 STUDY CARD 3. ADAPTER, KEYBOARD, CABLES, ETC


PROGRAM:
ORG 1000H MOV AL,17H OUT 0C0H, AL MOV AL,08H OUT 0C2H, AL MOV AL,01H OUT 0C2H, AL MOV AL,FEH OUT 0C2H, AL STI HERE: JMP HERE MOV AL,20H LOOP 0C0H,AL INT 02H Interrupt Vector:0000:0200 00h 0000:0021 12h 0000:0022 00h 0000:0023 00h

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8259 is done and results are observed.

EXERCISE:
1. 2. 3. 4. 5.

4. 8251 USART
AIM: To interface USART (Universal Synchronous Asynchronous Receiver Transmitter) with 8086 microprocessor. APPARATUS:

2 3
PROGRAM:

8086 TRAINER KIT 8251 STUDY CARD ADAPTER, KEYBOARD, CABLES, ETC

TRANSMITTER END: ORG 1000H MOV AL,36H OUT 0CEH, AL MOV AL,10H OUT 0C8H, AL MOV AL,00H OUT 0C8H, AL MOV AL,4EH OUT 0C2H, AL MOV AL,37H OUT 0C2H, AL LOOP1:IN AL,0C2H AND AL,04H JZ LOOP1 MOV AL,41H OUT 0C0H,AL INT 02H RECEIVER END: ORG 1200H MOV AL,36H OUT 0CEH, AL MOV AL,10H OUT 0C8H, AL MOV AL,00H OUT 0C8H, AL MOV AL,4EH OUT 0C2H, AL MOV AL,37H OUT 0C2H, AL LOOP2:IN AL,0C2H AND AL,04H JZ LOOP2 IN AL,0C0H MOV BX,I500H MOV [BX],AL INT 02H

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
8086 Interfacing with 8251 is done and results are observed.

EXERCISE for 8251: 1. Why we are calling it as USART? 2.Draw the format of mode word? 3.What is the use of TXEMPTY signal? 4.How many data lines in 8251?

1.1 8-BIT ADDITION


AIM: To perform addition of two 8-bit hex numbers stored in consecutive
memory locations and store the result in the next memory location.

APPARATUS:

2
PROGRAM:

8051 Microcontroller Kit ADAPTER, KEYBOARD, CABLES, ETC

CLC C MOV DPTR,#9000 MOVX A,@DPTR MOV B,A INC DPTR MOVX A,@DPTR ADD A,B INC DPTR MOVX @DPTR,A END: SJMP END

;Clear carry flag ;First data in B ;Second data in A ;sum in A ;Result in [9002h] ;Halt

OBSERVATIONS:
Input: Output: [9000h] = [9001h] = [9002h] =

RESULT:
Addition of two 8-bit numbers stored at consecutive memory locations is performed on 8051 microcontroller and the result is stored at the next memory location.

16-BIT ADDITION
AIM: To perform addition of two 16-bit hex numbers using immediate
addressing and store the result in memory location.

APPARATUS:
1

2
PROGRAM:

8051 Microcontroller Kit ADAPTER, KEYBOARD, CABLES, ETC

CLC C MOV A,#LSB1

;Clear carry flag

END:

ADDC A,#LSB2 MOV DPTR,#9001 MOVX @DPTR,A MOV A,#MSB1 ADDC A,#MSB2 INC DPTR MOVX @DPTR,A SJMP END

;First data in B ;Second data in A ;sum in A ;Result in [9002h] ;Halt

OBSERVATIONS:
Example: Output: DATA1 = 1234h DATA2 = 5678h [9000h] = [9001h] =

RESULT:
Addition of two 16-bit numbers is performed on 8051 microcontroller and the result is stored in memory.

1.2 SUBTRACTION
AIM: To perform subtraction of two 8-bit hex numbers stored in consecutive
memory locations and store the result in the next memory location.

APPARATUS:

2
PROGRAM:

8051 Microcontroller Kit ADAPTER, KEYBOARD, CABLES, ETC

CLC C MOV DPTR,#9001

;Clear carry flag

END:

MOVX A,@DPTR MOV B,A DEC DPTR MOVX A,@DPTR SUBB A,B INC DPTR INC DPTR MOVX @DPTR,A SJMP END ;Halt

;Second data in B ;First data in A ;Difference in A ;Result in [9002h]

OBSERVATIONS:
Input: Output: [9000h] = [9001h] = [9002h] =

RESULT:
Subtraction of two 8-bit numbers stored at consecutive memory locations is performed on 8051 microcontroller and the result is stored at the next memory location.

1.3 MULTIPLICATION
AIM: To perform multiplication of two 8-bit hex numbers stored in consecutive
memory locations and store the result in the next memory location.

APPARATUS:

2
PROGRAM:

8051 Microcontroller Kit ADAPTER, KEYBOARD, CABLES, ETC

CLC C MOV DPTR,#9001

;Clear carry flag

END:

MOVX A,@DPTR MOV B,A DEC DPTR MOVX A,@DPTR MUL AB INC DPTR INC DPTR MOVX @DPTR,A MOV B,A MOVX @DPTR,A SJMP END ;Halt

;Second data in B ;First data in A ;Difference in A ;Result in [9002h] ; and [9003h]

OBSERVATIONS:
Input: Output: [9000h] [9001h] [9002h] [9003h] = = = =

RESULT:
Multiplication of two 8-bit numbers stored at consecutive memory locations is performed on 8051 microcontroller and the result is stored at the next memory location.

1.4 DIVISION
AIM: To perform division of two 8-bit hex numbers stored in consecutive
memory locations and store the result in the next memory location.

APPARATUS:

2
PROGRAM:

8051 Microcontroller Kit ADAPTER, KEYBOARD, CABLES, ETC

CLC C MOV DPTR,#9001

;Clear carry flag

END:

MOVX A,@DPTR MOV B,A DEC DPTR MOVX A,@DPTR DIV AB INC DPTR INC DPTR MOVX @DPTR,A MOV B,A MOVX @DPTR,A SJMP END ;Halt

;Second data in B ;First data in A ;Difference in A ;Quotient in ; [9002h] and ;Remainder in ; [9003h]

OBSERVATIONS:
Input: Output: [9000h] [9001h] [9002h] [9003h] = = = =

RESULT:
Division of two 8-bit numbers stored at consecutive memory locations is performed on 8051 microcontroller and the result is stored at the next memory location.

2. DATA TRANSFER
AIM: To Transfer a block of data from internal ROM to external RAM APPARATUS: 1 8051 TRAINER KIT ADAPTER, KEYBOARD, CABLES, ETC

2
PROGRAM:

ORG 0000H START: MOV A,#00 MOV SP,#07H

MOV R3,#11 MOV DPTR,#200H PUSH DPL PUSH DPH REP: MOV DPTR,#MESSAGE MOV R2,A MOVC A,@A+DPTR POP DPH POP DPL MOVX @DPTR,A INC DPTR PUSH DPL PUSH DPH INC R2 MOV A,R2 DJNZ R3,REP MESSAGE: DB "HELLO WORD" END

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Block of data is transferred from ROM to RAM.

3. UNDERSTANDING ADDRESING MODES


AIM: To copy the value 55H into RAM memory locations 40H to 41H using (a) Direct addressing mode, (b) Register indirect addressing mode without a loop, and (c) with a loop

APPARATUS: 1

8051 TRAINER KIT ADAPTER, KEYBOARD, CABLES, ETC

PROGRAM:

(a)
MOV A,#55H MOV 40H,A MOV 41H.A ;load A with value 55H ;copy A to RAM location 40H ;copy A to RAM location 41H

(b)
MOV A,#55H MOV R0,#40H MOV @R0,A INC R0 MOV @R0,A ;load A with value 55H ;load the pointer. R0=40H ;copy A to RAM R0 points to ;increment pointer. Now R0=41h ;copy A to RAM R0 points to

(c)
MOV A,#55H MOV R0,#40H MOV R2,#02 AGAIN: MOV @R0,A INC R0 DJNZ R2,AGAIN ;A=55H ;load pointer.R0=40H, ;load counter, R2=3 ;copy 55 to RAM R0 points to ;increment R0 pointer ;loop until counter = zero

OBSERVATIONS:
(a)

(b)

(c)

RESULT:
A value is copied into RAM locations using various addressing modes and observed the differences.

4. UNDERSTANDING THE USAGE OF LCALL INSTRUCTION


AIM: To demonstrate the usage of LCALL instruction APPARATUS: 1

2
PROGRAM:
BACK:

8051 TRAINER KIT ADAPTER, KEYBOARD, CABLES, ETC

ORG 0 MOV A,#55H MOV P1,A

;load A with 55H ;send 55H to port 1

LCALL DELAY MOV A,#0AAH MOV P1,A LCALL DELAY SJMP BACK

;time delay ;load A with AA (in hex) ;send AAH to port 1 ;keep doing this indefinitely

DELAY: AGAIN:

ORG 300H MOV R5,#0FFH DJNZ R5,AGAIN RET END;

;put DELAY at address 300H ;R5=255 (FF in hex), counter ;stay here until R5 become 0 ;return to caller (when R5 =0)

OBSERVATIONS:
INPUT: OUTPUT:

RESULT:
Used LCALL instruction and observed the values of memory pointers

5. UNDERSTANDING THE USAGE OF ACALL INSTRUCTION


AIM: To demonstrate the usage of ACALL instruction APPARATUS: 1

2
PROGRAM:

8051 TRAINER KIT ADAPTER, KEYBOARD, CABLES, ETC

ORG 0

BACK:

MOV A,#55H MOV P1,A ACALL DELAY CPL A SJMP BACK ORG 300H MOV R5,#0FFH DJNZ R5,AGAIN RET END

;load A with 55H ;send 55H to port 1 ;time delay ;complement reg A ;keep doing this indefinitely ;put DELAY at address 300H ;R5=255 (FF in hex), counter ;stay here until R5 become 0 ;end of asm file

DELAY: AGAIN:

OBSERVATIONS:
INPUT:

OUTPUT:

RESULT:
Used ACALL instruction and observed the values of memory pointers

6. UNDERSTANDING THREE MEMORY AREAS OF 00-FF


AIM: To understand three memory areas of 00-FF APPARATUS: 1

2
PROGRAM:

8051 TRAINER KIT ADAPTER, KEYBOARD, CABLES, ETC

ORG 0000H LJMP START

START:

ORG 200H MOV A,#41H MOV 20H,A MOV A,#42H MOV R0,#20H MOV @R0,A MOV A,#43H MOV 80H,A MOV A,#44H MOV R0,#80H MOV @R0,A END

OBSERVATIONS:
INPUT:

OUTPUT:

RESULT:
Used the memory areas of Controller and observed the differences.

Expected Questions from Microprocessors:1. 2. 3. 4. 5. 6. 7. 8. 9. Who Invented 8086 microprocessor? In which year 8086 microprocessor is invented? How many address lines are available on 8086? How many data lines are available on 8086? Why address bus is unidirectional? Whether data bus is unidirectional or bidirectional? What is a bus? If AL=0FFh and ADD AL,01h instruction is executed, what is the status of status flags? Under what condition bus contention occurs?

10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44.

How can you avoid bus contention? The segment 1234h and offset is 0022h, then the physical address is? If an instruction is accessed by 8086 is 20ms, the time taken by 8088 is? The no. of cycles required by 8086 for writing/reading to/from memory/IO ports is? Whether 8086 contains internal clock generator? 8086 requires external clock signal with a duty cycle of? In 8086 the lower bank of 8086 contains? When ready pin of 8086 is at logic 0 then wait states are The vectored interrupt in 8086 is? Non vectored interrupt in 8086 is? To restart from the initial state when 1 is placed on 8086 RESET pin, the duration for which the signal must present is? The rate of transmission in serial mode is? In serial I/O, data transmission takes place using which code? USART converts data from which form to which from? The inputs and outputs of 8251 are compatible with which logic? Whether RS232C is compatible with TTL Logic? If TxD output remains high the 8251 contains which characters? In RS232C, RS stands for? In RS 232C standard uses positive logic or negative logic? Which transmission is used for high speed serial data transmission? Expand DCE and DTE? Which type of ADC is the fastest one? Which type of ADC is the most expensive one? Which type of ADC used DAC inside? How many comparators are required by an 8-bit flash type ADC? In 8259 if IR3, IR6, IR7 are activated, which interrupt has the highest priority? Which register in 8259 is used to disable interrupt requests? Which ports are used in BSR mode of 8255? Which port provides hand shaking signals in Mode1 & Mode2 of 8255? What is the IC used for DMA transfer? How many peripherals can be connected to 8237 at any point of time? For bidirectional data transfer, 8255 is operated in which mode? DMA will send a request signal to which pin of 8086? Which instruction is used to return from the interrupt service procedure? What are the ICs MC 1488 and MC 1489?

45. 46. 47. 48. 49. 50.

When accessing a memory location shared with a coprocessor, the signal that prevents the coprocessor from accessing that location is? There are two no. of 2Kx8 memory chips. How to obtain 4Kx8 memory? When the processor has 32 address lines, how much memory can be interfaced to that processor? Whether Stepper Motor is an AC Motor or DC Motor? Give any application of Stepper Motor in our real life? What do you mean by interfacing?

Expected Questions from Microcontrollers:1. Who has introduced MCS-51 family of microcontrollers? 2. MCS-51 family of microcontrollers contains which ICs? 3. What is the difference between MP and MC? 4. Give any Example of Microcontrollers? 5. Is 8051 an 8-bit controller? 6. Why 8051 is an 8-bit controller? 7. What is the on chip ROM capacity of 8051? 8. What is the on chip RAM capacity of 8051? 9. How many IO ports are available on 8051 on chip?

10. How many timers are available on 8051 on chip? 11. Which version of 8051 doesnt have on chip ROM? 12. Which version of 8051 contains EPROM on chip? 13. 8051 contains which type of ROM? 14. What is the purpose of ROM in 8051? 15. What is the purpose of RAM in 8051? 16. Whether ROM is accessible randomly or not? 17. What is the capacity of on chip EPROM on 8751? 18. Can you connect external program memory to 8051? 19. Can you connect external data memory to 8051? 20. What is the capacity of external program memory that can be connected to 8051? 21. What is the capacity of external data memory that can be connected to 8051? 22. How can you access internal program memory? 23. How can you access external program memory? 24. How is it possible to access both internal & external ROM using PC? 25. How can you access internal data memory? 26. How can you access external data memory? 27. Do you require any signal to access external data memory? 28. Do you require any signal to access external program memory? 29. What is the reason behind connecting only 64KB of external program memory? 30. What is the reason behind connecting only 64KB of external data memory? 31. Expand DPTR? 32. Is a DPTR an 8-bit register? 33. Can we access PC as two 8-bit registers? 34. Is there any register in 8086 similar to PC in 8051? 35. Expand SFR? 36. Is PC a special function register? 37. Whether external interrupts are edge triggered or level triggered type? 38. Expand ALE? 39. Expand PSEN? 40. What is the function of PSEN pin? 41. For serial communication the pins of which IO port is used? 42. Which register is used to operate 8051 in different modes? 43. What are the modes of operation of 8051? 44. Whether PCON is a bit addressable SFR?

45. Which port will hold the higher order address information during memory access? 46. Which Io port of 8051 doesnt have dual function? 47. What is the Architecture of 8051? 48. What is stack? 49. What is the function of SP register? 50. The number of clock cycles in one machine cycle of 8051 is?

Key to the Questions on Microprocessors:1.Intel Corporation, 2.1974, 3.20 address lines, 4.16 data lines,

5.The address bus is unidirectional because the information on the address bus is always provided by the microprocessor, control signals, 6.Data bus is bidirectional. 7.Bus is a collection of signal lines. Generally they carry address, data and 8.CF=1, PF=1, AF=1, ZF=1, SF=0 and OF=0 9.Bus contention occurs when two outputs trying to drive the same line. 10.Bus contention can be avoided by using tri-state condition which isolates one of the outputs, 11.12362h, 12.40ms, 13.4 clock cycles, 14.No

15.33% duty cycle for its optimal functioning, 17.Between T3 and T4 states, 21.Baud, 22.ASCII, 26.No data (Stop bits), 18.NMI, 19.INTR, 23.Parallel form to Serial,

16.Even address locations, 20.4 clock cycles, 24.TTL Logic, 28.Negative logic, 31.Flash type ADC, 34.8 25.No,

27.Recommended Standard,

29.Synchronous transmission,

30.DCE stands for Data Communications 33.Successive Approximation ADC, 37.Only Port C bits, 40.Four, 46.By
32

Equipment and DTE stands for Data Terminal Equipment, 32.Successive Approximation ADC, Comparators, 35.IR3, 36.Interrupt Mask Register,

38.Port C provides hand shaking signals,

39.8237 or 8257, 47.2

41.Mode 2, 42.HOLD pin, 43.IRET, 44.Voltage translators, 45. LOCK , connecting address lines in serial and data lines parallel, Motor, 49.Printers, X-Y plotters, Hard disk/Floppy Disk Drives, etc.,

= 4GB, 48.DC

50.Interfacing means not only connecting the devices but also communicating between them.

Key to the Questions on Microcontrollers:1.Intel Corporation, 2.8031, 8051, 8052, 8751 and 8752 Microcontrollers,

3.MP contains ALU, Control Unit and On chip memory where as Microcontroller contains MP, ROM, RAM, IO Ports, Counters/Timers on chip, 4.8051, 5.Yes, 6.Because all the internal registers and accumulator are of 8-bit wide and they can process 8-bit data, 7.4KB, 8.128 bytes, 9.4 no. of 8-bit IO Ports, 10.2 no. 13.Simple Read Only Memory, of 16-bit Timers/Counters, 11.8031, 12.8751,

14.ROM is used for storing Programs hence it is called as Program Memory,

15.RAM is nothing but Data Memory and is used to store data, 16.Yes, 18.Yes, 19.Yes, 20.64KB, 21.64KB, 22.Program Counter,

17.4KB,

23.Program Counter, 24.Whenever we access external program memory, we use MOVX instruction which distinguish the internal & external ROM, 25.By means of its address in the program instructions, 26.Data Pointer, 27.Yes. We require Logic 0 on External Access pin, 28.No signal is required to access external program memory, 29.Because PC is a 16-bit register, the maximum memory that can be interfaced externally is 216 = 64KB only, 30.DPTR is a 16-bit register; the maximum memory that can be interfaced externally is 216 = 64KB only, 31.Data Pointer, 32.DPTR is a 16-bit register, but we can access it as two 8-bit registers DPH & DPL, 33.No, we cant access PC as two 8-bit registers, 34.PC is very similar to IP register in 8086, 35.SFR stands 36.No, PC is the only register which doesnt come for Special Function register,

under SFR,37.They can be programmed as either edge triggered or level triggered,38.Address Latch Enable, 39.PSEN stands for Program Store Enable, 40.PSEN is used to store program in external memory, 41.Port 3 pins are used for serial communication, 42.PCON(Power CONtrol) SFR is used,43.Power Down 46.Port 1 pins have no Mode and Idle Mode, 44.No. PCON is not bit addressable, 45.Port 2 will hold the higher order address information during memory access, dual functions, 47.The Architecture of 8051is called Harvard Architecture, 48.Stack is an area in internal RAM that is used in conjunction with certain opcodes to store and retrieve data quickly, 49.SP holds an internal RAM address that is called top of the stack, 50.12 clock cycles.

Vous aimerez peut-être aussi