Aiet MP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

ALVA’S INSTITUTE OF ENGINEERING & TECHNOLOGY

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

th
6 Semester E & C
Laboratory Manual
MICROPROCESSOR LAB
06ECL – 68
Prepared by: Mahesh Prasanna K.
Approved by: Head of the Department

Name: ………………………………………………..……..…

USN:……………………………..……. Batch:……..…..…..
Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

Alva‟s Institute of Engineering & Technology, Moodbidri 2


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

*************************************************************************************
INDEX
Page No.
Part – A: Software Programs

8086 Instruction Set 04


Tasm/Masm Commands 09

1. Data Transfer in different addressing modes 10


2. Block Move 12
3. Block Interchange 14
4. Addition of multi precision numbers 15
5. Subtraction of multi precision numbers 15
6. Unsigned multiplication 15
7. Unsigned division 17
8. ASCII Adjustment programs 18
9. Code Conversion 20
10. Arithmetic Programs 23
11. Bit Manipulation Programs 25
12. Programs on Arrays 30
13. String Manipulation Programs 31

DOS Interrupts 34

14. Strings 38
Part – B: Interfacing Programs

Delay Calculations 42

15. Keyboard Interface 43


16. 7 Segment Display Interface 46
17. Logical Controller Interface 50
18. Stepper Motor Interface 52
19. Printer Interface 55

Viva Questions & Question bank 56

*************************************************************************************

Alva‟s Institute of Engineering & Technology, Moodbidri 3


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

8086Instruction Set
Instructions Operands Description
MOV REG, memory Copy operand2 to operand1.
memory, REG The MOV instruction cannot:
REG, REG Set the value of the CS and IP registers.
memory, immediate Copy value of one segment register to another segment register
REG, immediate (should copy to general register first).
Copy immediate value to segment register (should copy to general
SREG, memory
register first).
memory, SREG
Algorithm: operand1 = operand2
REG, SREG Ex:
SREG, REG
Mov AX,BX ;Copy contents of BX to AX
Mov si,00h ;load Si with 00h
MUL REG Unsigned multiply.
Memory Multiply the contents of REG/Memory with contents of AL register.
Algorithm:
When operand is a byte:
AX = AL * operand.
When operand is a word:
(DX: AX) = AX * operand.
CMP REG, memory Compare.
memory, REG
REG, REG Algorithm: operand1 - operand2
memory, immediate Result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF)
REG, immediate according to result.
JMP Label Unconditional Jump.
Transfers control to another part of the program. 4-byte address may be
entered in this form: 1234h: 5678h, first value is a segment second value is
an offset.
Algorithm: always jump

Jump If Above.
Short Jump if first operand is Above second operand (as set by CMP
JA Label instruction). Unsigned.
Algorithm: if (CF = 0) and (ZF = 0) then jump
Jump If Above Or Equal
Short Jump if first operand is Above or Equal to second operand (as set by
JAE Label CMP instruction). Unsigned.
Algorithm: if CF = 0 then jump
JB Label Jump If Below.
Short Jump if first operand is Below second operand (as set by CMP
instruction). Unsigned.
Algorithm: if CF = 1 then jump
JBE Label Jump If Below Or Equal
Short Jump if first operand is Below second operand (as set by CMP
instruction). Unsigned.
Algorithm: if CF = 1 then jump
JC Label Jump If Carry
Short Jump if Carry flag is set to 1.
Algorithm: if CF = 1 then jump

Alva‟s Institute of Engineering & Technology, Moodbidri 4


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

JE Label Jump If Equal.


Short Jump if first operand is Equal to second operand (as set by CMP
instruction). Signed/Unsigned.
Algorithm: if ZF = 1 then jump
JG Label Jump If Greater
Short Jump if first operand is Greater, then second operand (as set by CMP
instruction). Signed.
Algorithm: if (ZF = 0) and (SF = OF) then jump
JGE Label Jump If Greater Or Equal.
Short Jump if first operand is Greater or Equal to second operand (as set by
CMP instruction). Signed.
Algorithm: if SF = OF then jump
JL Label Jump If Less than.
Short Jump if first operand is Less then second operand (as set by CMP
instruction). Signed.
Algorithm: if SF <> OF then jump
JLE Label Jump If Less Or Equal.
Short Jump if first operand is Less or Equal to second operand (as set by
CMP instruction). Signed.
Algorithm: if SF <> OF or ZF = 1 then jump

JNZ Label Jump If Non Zero.


Short Jump if Not Zero (not equal). Set by CMP, SUB, ADD, TEST, AND,
OR, XOR instructions.
Algorithm: if ZF = 0 then jump

JZ Label Jump If Zero.


Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST, AND, OR,
XOR instructions.
Algorithm: if ZF = 1 then jump

LEA REG, memory Load Effective Address.

Algorithm:
REG = address of memory (offset)
LOOP Label Decrease CX, jump to label if CX not zero.

Algorithm:
CX = CX - 1
if CX <> 0 then
o jump
else
o no jump, continue
ADD REG, memory Add.
memory, REG
REG, REG Algorithm:
memory, immediate operand1 = operand1 + operand2
REG, immediate

Alva‟s Institute of Engineering & Technology, Moodbidri 5


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

AND REG, memory Logical AND between all bits of two operands. Result is stored in operand1.
memory, REG These rules apply:
REG, REG 1 AND 1 = 1; 1 AND 0 = 0
memory, immediate 0 AND 1 = 0; 0 AND 0 = 0
REG, immediate
OR REG, memory Logical OR between all bits of two operands. Result is stored in first
memory, REG operand.
REG, REG These rules apply:
memory, immediate 1 OR 1 = 1; 1 OR 0 = 1
REG, immediate 0 OR 1 = 1; 0 OR 0 = 0
SUB REG, memory Subtract.
memory, REG
REG, REG Algorithm:
memory, immediate operand1 = operand1 - operand2
REG, immediate
DAA No Operands Decimal adjust After Addition.
Corrects the result of addition of two packed BCD values.
Algorithm:
if low nibble of AL > 9 or AF = 1 then:
AL = AL + 6
AF = 1
if AL > 9Fh or CF = 1 then:
AL = AL + 60h
CF = 1
DAS No Operands Decimal adjust After Subtraction.
Corrects the result of subtraction of two packed BCD values.
Algorithm:
if low nibble of AL > 9 or AF = 1 then:
AL = AL - 6
AF = 1
if AL > 9Fh or CF = 1 then:
AL = AL - 60h
CF = 1
INC REG Increment.
memory
Algorithm: operand = operand + 1

DEC REG Decrement.


Memory
Algorithm: operand = operand – 1

DIV REG Unsigned divide.


Memory
Algorithm:
when operand is a byte:
AL = AX / operand
AH = remainder (modulus)
when operand is a word:
AX = (DX AX) / operand
DX = remainder (modulus)

Alva‟s Institute of Engineering & Technology, Moodbidri 6


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

SHL memory, immediate Shift Left.


REG, immediate Shift operand1 Left. The number of shifts is set by operand2.
Algorithm:
memory, CL Shift all bits left, the bit that goes off is set to CF.
REG, CL Zero bit is inserted to the right-most position.
SHR memory, immediate Shift Right.
REG, immediate Shift operand1 Right. The number of shifts is set by operand2.
Algorithm:
memory, CL Shift all bits right, the bit that goes off is set to CF.
REG, CL Zero bit is inserted to the left-most position.
ROL memory, immediate Rotate Left.
REG, immediate Rotate operand1 left. The number of rotates is set by operand2.
Algorithm:
memory, CL Shift all bits left, the bit that goes off is set to CF and the same bit
REG, CL is inserted to the right-most position.
ROR memory, immediate Rotate Right.
REG, immediate Rotate operand1 right. The number of rotates is set by operand2.
Algorithm:
memory, CL Shift all bits right, the bit that goes off is set to CF and the same
REG, CL bit is inserted to the left-most position.
RCL memory, immediate Rotate operand1 left through Carry Flag. The number of rotates is set by
REG, immediate operand2.
Algorithm:
memory, CL Shift all bits left, the bit that goes off is set to CF and previous
REG, CL value of CF is inserted to the right-most position.
Example:
STC ; set carry (CF=1).
MOV AL, 1Ch ; AL = 00011100b
RCL AL, 1 ; AL = 00111001b, CF=0.
RET
C O
r r
OF=0 if first operand keeps original sign.
CALL procedure name Transfers control to procedure, return address is (IP) pushed to stack.
label
RET No operands Return from near procedure.
Or even immediate Algorithm:
date Pop from stack:
o IP
if immediate operand is present: SP = SP + operand

IN AL, im.byte Input from port into AL or AX.


AL, DX Second operand is a port number. If required to access port number over
AX, im.byte 255 - DX register should be used.
AX, DX
OUT AL, im.byte Output from AL or AX to port.
AL, DX First operand is a port number. If required to access port number over 255 -
AX, DX DX register should be used.
POP REG Get 16 bit value from the stack.
SREG Algorithm: Operand = SS : [SP](top of stack)
memory SP = Sp + 2.

Alva‟s Institute of Engineering & Technology, Moodbidri 7


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

PUSH REG Store 16 bit value in the stack.


SREG Algorithm:
memory SP = SP - 2
SS:[SP] (top of the stack) = operand
XOR REG, memory Logical XOR (Exclusive OR) between all bits of two operands. Result is
memory, REG stored in first operand.
REG, REG These rules apply:
memory, immediate 1 XOR 1 = 0; 1 XOR 0 = 1
REG, immediate 0 XOR 1 = 1; 0 XOR 0 = 0
XCHG REG, memory Exchange values of two operands.
memory, REG Algorithm: operand1 < - > operand2
REG, REG
XLAT No Operands Translate byte from table.
Copy value of memory byte at DS:[BX + unsigned AL] to AL register.
Algorithm: AL = DS:[BX + unsigned AL]
AAA No Operands ASCII Adjust after Addition.
Corrects result in AH and AL after addition when working with BCD
values.
Algorithm:
if low nibble of AL > 9 or AF = 1 then:
AL = AL + 6
AH = AH + 1
AF = 1
CF = 1
else
AF = 0
CF = 0
in both cases:
clear the high nibble of AL.
Example:
MOV AX, 15 ; AH = 00, AL = 0Fh
AAA ; AH = 01, AL = 05
AAS No Operands ASCII Adjust after Subtraction.
Corrects result in AH and AL after subtraction when working with BCD
values.
Algorithm:
if low nibble of AL > 9 or AF = 1 then:
AL = AL - 6
AH = AH - 1
AF = 1
CF = 1
else
AF = 0
CF = 0
in both cases:
clear the high nibble of AL.
Example:
MOV AX, 02FFh ; AH = 02, AL = 0FFh
AAS ; AH = 01, AL = 09
AAM No Operands ASCII Adjust after Multiplication.
Corrects the result of multiplication of two BCD values.
Algorithm: Example:
AH = AL / 10 MOV AL, 15 ; AL = 0Fh
AL = remainder AAM ; AH = 01, AL = 05

Alva‟s Institute of Engineering & Technology, Moodbidri 8


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

TASM COMMANDS

Start Run… cmd

C : \ cd tasm
C : \ tasm > edit filename.asm

.model type
.data

Body of the data segment


.code
start : mov ax,@data
mov ds,ax
. Body of the code segment
. .
end start
C : \ tasm > tasm filename.asm
C : \ tasm > tlink filename.obj
C : \ tasm > afdebug filename.exe OR C : \ tasm > iopm filename.exe portno. [Interfacing kits]

NOTE: 1. Model type can be tiny (No DS, 1CS)


small (1DS, 1CS)
medium (1DS, >1CS)
large (>1DS, >1CS)
NOTE: 2. In afdebug command prompt use the following commands;
F1 – for single step execution of the program
G – for the execution of entire program at a time
Quit – to exit from the afdebug screen
Alt+Enter – to maximize/minimize the screen

MASM COMMANDS
C :/>cd foldername
C:/foldername>edit filename.asm
After this command executed in command prompt an editor window will open. Program should be typed in this
window and saved. The program structure is given below.
.model tiny/small/medium/large
.Stack <some number>
.data
; Initialize data which is used in program.
.code
; Program logic goes here.
end

C:/foldername>masm filename.asm
After this command is executed in command prompt if there are no errors in program regarding to syntax the assembler
will generates an object module as discuss above.

C:/foldername>link filename.obj
After verifying the program for correct syntax and the generated object files should be linked together. For this the
above link command should be executed and it will give an EXE file if the model directive is small as discuss above.

C:/foldername>debug filename.exe
After generating EXE file by the assembler it‟s the time to check the output. For this the above command is used and
the execution of the program can be done in different ways. It is as shown below:
__ g ; complete execution of program in single step.
__ t ; Stepwise execution.
__ d ds: starting address or ending address ; To see data in memory locations
__ p ; Used to execute interrupt or procedure during stepwise execution of program
__ q ; To quit the execution.

Alva‟s Institute of Engineering & Technology, Moodbidri 9


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

1. A) ALP TO MOVE THE DATA BETWEEN THE REGISTERS.


.model small
.data
num1 db 50h

.code
start: mov ax,@data
mov ds,ax ; Data segment initialization

mov al,num1
mov ah,al
mov bh,ah ; Moves data between 8 bit registers
mov ch,bh
mov cl,ch
int 3 ; Terminates the program execution
align 16 ; DS starts from page boundary
end start

1. B) ALP TO MOVE THE DATA BETWEEN 16 BIT REGISTERS


.model small
.data
num1 dw 2505h
.code
start: mov ax,@data
mov ds,ax ; Initializes Data segment

mov ax,num1
mov bx,ax
mov cx,bx ; Moves data between 16 bit registers
mov dx,ax
int 3 ; Terminates the program execution
align 16 ; DS starts from page boundary
end start

1. C) ALP TO MOVE 8 BIT IMMEDIATE DATA


.model tiny
.code
start: mov al,10h
mov bl,20h
mov cl,30h ; Moves immediate value to 8 bit registers
mov ah, 40h
mov ch,50h
mov bh,60h
mov dl,al
mov dh,ah
int 3 ; Terminates the program execution
end start

Alva‟s Institute of Engineering & Technology, Moodbidri 10


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

1. D) ALP TO MOVE 16 BIT IMMEDIATE DATA.


. model tiny
. code
start: mov ax,1234h
mov bx, 1500h ; Moves immediate value to 16 bit registers
mov cx, 5678h
mov si, 4000h
mov dx, 1000h
int 3 ; Terminates the program execution
align 16 ; DS starts from page boundary
end start
NOTE: The ALIGN 16 directive forces the assembler to align the next segment at an address that is divisible by 16 (10h).

1. E) ALP TO ADD TWO BYTES


.model small
.data
num1 db 25h
num2 db 75h
rslt db ?
.code
begin : mov ax,@data ; Initializes Data segment
mov ds,ax

mov al,num1
mov bl,num2
add al,bl ; Adds the 2 bytes
mov rslt,al ; Result in memory
int 3
align 16 ; DS starts from page boundary
end begin

1. F) ALP TO ADD TWO WORDS


.model small
.data
num3 dw 0fe10h
num4 dw 1243h
rslt dw ?
.code
start: mov ax,@data
mov ds,ax ; Initializes Data segment

mov ax, num3


add ax, num4 ; Adds the 2 words
mov rslt,ax ; Result in memory
int 3 ; Terminates the program execution
align 16
end start
NOTE: For subtraction use SUB instead of ADD in the above program

Alva‟s Institute of Engineering & Technology, Moodbidri 11


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

2. A) ALP TO MOVE DATA FROM SOURCE TO DESTINATION USING INDIRECT ADDRESSING MODE
(Block move without overlap)
.model small
.data
src db 10h,20h,30h,40h,50h
cnt equ ($-src)
dst db int dup(0)
.code
start: mov ax,@data
mov ds,ax ; DS intialization

mov si,offset src ; Points SI to source


mov di,offset dst ; Points DI to destination
mov cx,cnt
back: mov al,[si]
mov [di],al ; Moves data from source address
inc si ; to destination address
inc di
loop back

int 3 ; Terminates the program execution


align 16 ; DS starts with page boundary
end start

NOTE : 1) The function of mov si, offset src is same as lea si, src
Therefore in the above program lea si, src and lea di, dst can be used.
2) When we use loop instruction the counter value should be in CX.
This instruction decrements CX, checks for CX ≠ 0, if so, it loops backs to the label specified with this
instruction.

2. B) ALP TO MOVE A BLOCK OF DATA FROM SOURCE TO DESTINATION


WITH OVERLAP IN EITHER DIRECTION
.model small
.data
blk_len equ 0ah
src equ 0014h
dst equ 001ah
nums db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah
.code
start: mov ax,@data
mov ds,ax ; DS initialization
mov es,ax ; ES initialization

mov si,00
mov cx,blk_len

lddt: mov dl,nums[si] ; Loading the data starting


mov src[si],dl ; from source address 'src'
inc si
loop lddt

Alva‟s Institute of Engineering & Technology, Moodbidri 12


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov si,src ; Initialization of source


mov di,dst ; & destination blocks along
mov cx,blk_len ; with their length

cmp si,di ; To decide whether source


jc btmtrf ; address is greater than
; destination address
top: cld ; Top transfer
trf : rep movsb
jmp ovr

btmtrf: add si,blk_len ; Bottom transfer


dec si
add di,blk_len
dec di
std
jmp trf

ovr: int 3 ; Terminates the program execution


align 16
end start

2. C) ALP TO MOVE BLOCK OF DATA WITHOUT OVERLAP(OTHER LOGIC)


.model small
.data
src dw 1111h,2222h,3333h
len equ ($-src)/2
dst dw len dup(0)
.code
start: mov ax,@data
mov ds,ax
mov es,ax ; Initializes DS & ES

cld ; Clears directional flag


mov cx,len ; Counter is initialized
lea si,src
lea di,dst
rep movsw ; Transfers words from source to destination

int 3 ; Terminates the program execution


align 16
end start
NOTE: 1) when we use string instructions in the program, along with the data segment (DS) extra segment (ES)
should be initialized.
2) If directional flag DF = 0, the pointers are incremented automatically, and
if DF = 1, the pointers are decremented automatically.
3) Rep is a prefix which is written before one of the string instructions. This rep prefix is a string operator
which assumes that, the counter is specified in CX register, it decrements CX by 1 and if it is not equal to zero then it
repeats the string instructions which are followed by it.

Alva‟s Institute of Engineering & Technology, Moodbidri 13


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

3. A) ALP TO INTERCHANGE TWO BLOCKS OF DATA


.model small
.data
src dw 1111h,2222h,3333h,4444h,5555h
dst dw 0aaaah,0bbbbh,0cccch,0ddddh,0eeeeh
cnt equ ($-dst)/2
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
lea si,src ; SI points to src
lea di,dst ; DI points to dst
mov cx,cnt ; Initializes CX with no. of words
; to be interchanged
back: mov ax,[si]
mov bx,[di]
mov [si],bx ; Interchanges src block and dst block
mov [di],ax
inc si
inc si
inc di
inc di
loop back ; Decrements the counter CX, checks for CX ≠ 0
int 3 ; and loops back to the label
align 16
end start

3. B) ALP TO INTERCHANGE TWO BLOCKS OF DATA (OTHER LOGIC )


.model small
.data
src dw 1111h,2222h,3333h,4444h,5555h
cnt equ ($-src)/2
dst dw 0aaaah,0bbbbh,0cccch,0ddddh,0eeeeh
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov si,0000h
mov cx,cnt
back: mov ax,[offset src+si]
mov bx,[offset dst+si]
mov [offset src+si],bx ; Interchanges src block and dst block
mov [offset dst+si],ax
inc si
inc si
loop back ; Decrements counter & loops back
int 3
align 16
end start

Alva‟s Institute of Engineering & Technology, Moodbidri 14


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

4. ALP TO ADD TWO MULTI-PRECISION NUMBERS


.model small
.data
num1 db 3Dh,62h,48h,0A3h ; Lower Byte first (num1-A348623Dh)
num2 db 8Ch,0B2h,76h,0FDh ; Lower Byte first (num2-FD76B28Ch)
len equ ($-num2)
res db len+1 dup(?)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov cx,len ; Sets counter for 4-byte addition
lea si,num1 ; Points SI to 1st multibyte no num1
lea di,num2 ; Points DI to 2nd multibyte no num2
lea bx,res ; Points BX to the result memory location
clc ; Clears carry flag CF

back: mov al,[si]


adc al,[di] ; Adds two multibyte nos byte by byte with carry
mov [bx],al ; starting from lower byte
inc si
inc di
inc bx
loop back
jnc zero ; Checks for CF = 0
inc cl
zero: mov [bx],cl ; Stores carry
int 3
align 16
end start

5. ALP TO SUBTRACT TWO MULTI-PRECISION NUMBERS


NOTE: For the subtraction of multi-precision numbers simply change the instruction ADC in the above program with
SBB instruction.

6. A) ALP TO MULTIPLY TWO 16 BIT NUMBERS


.model small
.data
mpr dw 0ffffh
mpd dw 0ffffh
res dw 5 dup(0)
.code
start: mov ax,@data
mov ds,ax ; DS initialization
mov ax,mpd
mov cx,mpr
mul cx ; Multiplies the two words
mov res,ax

Alva‟s Institute of Engineering & Technology, Moodbidri 15


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov res+2,dx
int 3 ; Terminates the program execution
align 16
end start

NOTE: (1) 16 * 16 = 32 bit result


AX * CX = DX : AX
Use any register

(2) 32 * 32 = 64 bit result


(mpdh)(mpdl) * (mprh)(mprl)

Save (DX) (AX) (mpdl) * (mprl)


(BX) Save the 1st part of the result

(DX) (AX) (mpdh) * (mprl)


(CX) (BX)

Cy (DX) (AX) (mpdl) * (mprh)


If carry (BX)(CX) (AX)
BX=0001 Save the 2nd part of the result
Else BX =0000 Cy
(DX) (AX) (mpdh) * (mprh)
(DX) (AX)
Save the last Save the 3rd part of the result
part of the result

6. B) ALP TO MULTIPLY TWO 32 BIT NUMBERS


.model small
.data
mpdl dw 0aaaah
mpdh dw 0bbbbh
mprl dw 0cccch
mprh dw 0ddddh
prod dw 8 dup(0)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov ax,mprl
mul mpdl
mov prod,ax ; Stores the 1st part of the result
mov bx,dx
mov ax,mprl
mul mpdh
add bx,ax
adc dx,0000

Alva‟s Institute of Engineering & Technology, Moodbidri 16


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov cx,dx
mov ax,mprh
mul mpdl
add ax,bx
mov prod+2,ax ; Stores the 2nd part of the result
adc cx,dx
mov bx,0000 ; If no carry
jnc next
mov bx,0001 ; if carry
next: mov ax,mprh
mul mpdh
add ax,cx
mov prod+4,ax ; Stores the 3rd part of the result
adc dx,bx
mov prod+6,dx ; Stores the last part of the result
int 3
align 16
end start

7. ALP TO DIVIDE 32-BIT UNSIGNED NUMBER BY 16-BIT NUMBER


.model small
.data
dvd dd 15752510h
dvr dw 0ffffh
quot dw ?
remd dw ?
.code
start: mov ax,@data
mov ds,ax ; DS initialization
mov si,offset dvd
mov ax,word ptr[si]
mov dx,word ptr[si+2]
mov cx,dvr
div cx
mov quot,ax
mov remd,dx

int 3
align 16
end start
NOTE: 1. CX) DX : AX (Q AX 16 ) 32 ( Quot – 16 bit

R DX Remd – 16 bit

2. CL ) AX ( Q AL 8 ) 16 ( Quot – 8 bit

R AH Remd – 8 bit

Alva‟s Institute of Engineering & Technology, Moodbidri 17


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

8. A) ALP TO ILLUSTRATE USE OF AAA INSTRUCTION (ASCII ADDITION)


.model small
.data
read macro ; Macro to read ASCII value
mov ah,01h ; from key board
int 21h
endm

write macro ; Macro to display ASCII value


mov ah,02h ; on screen
int 21h
endm
.code
start : mov ax,@data
mov ds,ax ; Initializes DS
read ; Reads 1st no.
mov bl,al
read ; Reads 2nd no.
mov ah,00
push ax
mov dl,20h ; Displays space on screen
write ; before the result
pop ax

add al,bl ; Result in hex


aaa ; Converts to unpacked BCD
add ax,3030h

push ax
mov dl,ah
write ; Displays higher nibble
pop ax
mov dl,al
write ; Displays lower nibble
mov ah,4ch ; Terminates the program execution
int 21h
end start
NOTE: ASCII value for space is 20h

8. B) ALP TO ILLUSTRATE USE OF AAS INSTRUCTION (ASCII SUBTRACTION)


.model small
.data
read macro ; Macro for read ASCII value from key board
mov ah,01h
int 21h
endm
write macro ; Macro to display ASCII value on screen
mov ah,02h
int 21h
endm

Alva‟s Institute of Engineering & Technology, Moodbidri 18


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

.code
start: mov ax,@data
mov ds,ax ; Initializes DS

read ; Reads first number


mov cl, al
read ; Reads second number
mov bl,al
mov al, cl

push ax
mov dl,20h ; Displays space on the screen before the result
write
pop ax

sub al, bl
jnc next

mov ah,00 ; If first < second


aas
mov bl,0ah
sub bl, al
or bl,30h

mov dl,2dh ; Displays „-„ on the screen


write

mov dl, bl
jmp last

next : aas ; If first > second


or al,30h
mov dl, al

last : write
mov ah,4ch ; Terminates the program
int 21h
end start

8. C) ALP TO ILLUSTRATE USE OF AAM INSTRUCTION (ASCII MULT)


.model small
.data
read macro ; Macro for read ASCII value from key board
mov ah,01h
int 21h
and al,0fh
endm

Alva‟s Institute of Engineering & Technology, Moodbidri 19


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

write macro ; Macro to display ASCII value on screen


mov ah,02h
int 21h
endm
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

read ; Reads first number


mov bl,al
read ; Reads second number

mul bl ; Result in Hex


aam ; Unpacked BCD result
or ax,3030h ; Result in ASCII

push ax
mov dl,20h ; Display space on the screen before the result
write
pop ax

push ax
mov dl, ah ; Displays higher byte result
write
pop ax

mov dl, al ; Displays lower byte result


write

mov ah,4ch
int 21h ; Terminates the program
end start

9. A) ALP TO CONVERT BINARY NUMBER TO BCD NUMBER


.model small
.data
tentho equ 2710h
tho equ 3e8h
hun equ 64h
ten equ 0ah
bin dw 0ffffh
bcd db 10 dup(0)
temp1 db 10 dup(0)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov ax,bin
cmp ax, tentho
jc abc
mov dx,0000h ; Obtain the BCD of ten thousand place
mov bx,tentho
div bx

Alva‟s Institute of Engineering & Technology, Moodbidri 20


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov temp1,al ; Places value in temp


mov bin,dx

abc: mov ax,bin


cmp ax,tho
jc cde
mov dx,0000h ; Obtain the BCD value of thousand place
mov bx, tho
div bx
mov temp1+1,al
mov bin,dx

cde: mov ax,bin


cmp ax,hun
jc def
mov dx,0000h ; Obtain the BCD value of
mov bx, hun ; hundred place
div bx
mov temp1+2,al
mov bin,dx

def: mov ax,bin


mov dx,0000h
mov bx, ten
div bx
mov temp1+3,al
mov temp1+4,dl
mov al,temp1+3
mov cl,04
rol al,cl
mov bl,temp1+4
or al,bl
mov bcd+2,al
mov al,temp1+1
mov cl,04
rol al,cl
mov bl,temp1+2
or al,bl
mov bcd+1,al
mov al,temp1
mov bcd,al

int 3
align 16
end start

Alva‟s Institute of Engineering & Technology, Moodbidri 21


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

9. B) ALP TO CONVERT BCD NUMBER TO BINARY NUMBER


model small
.data
tho equ 3e8h
hun equ 64h
ten equ 0ah
bcd dw 5160h
bin dw 2 dup(0)
temp dw 10 dup(0)
.code
start: mov ax,@data
mov ds,ax ; Initialize DS

mov ax,bcd
mov bx,ax
and ax,000fh
mov temp,ax
mov ax,bx
and ax,00f0h
mov cl,04
ror al,cl
mov si,ten
mul si
mov temp+2,ax
mov ax,bx
and ax,0f00h
mov al,ah
mov ah,00h
mov si,hun
mul si
mov temp+4,ax
mov ax,bx

and ax,0f000h
mov al,ah
mov ah,00h
mov cl,04h
ror al,cl
mov si,tho
mul si
add ax,temp
add ax,temp+2
add ax,temp +4
mov bin,ax
int 3
align 16
`end start

Alva‟s Institute of Engineering & Technology, Moodbidri 22


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

10. A) ALP TO FIND SQUARE AND CUBE OF A 16 BIT NUMBER


.model small
.data
num dw 0ffeeh
res dw 10 dup()
.code
start: mov ax, @data
mov ds, ax ; Initializes DS

mov si,offset num ; Points SI to data location


lea di, res ; Points DI to result location
mov ax,[si] ; Gets the number
mul ax ; Finds square of a given no.
mov [di],ax
mov [di+2],dx ; Stores the square in memory

mov ax,[si] ; Finds cube of a given no.


mul word ptr[di]
mov [di+4],ax
mov bx, dx

mov ax,[si]
mul word ptr[di+2]
add ax, bx
adc dx,0000
mov [di+6],ax
mov [di+8],dx
int 3
align 16
end start

10. B) ALP TO FIND LCM OF TWO 8-BIT NUMBERS


.model small
.data
nums dw 0010,0048
lcm dw 2 dup (?)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov ax,nums
mov cx,nums+2
mov dx,00h
back: push ax
push dx
div cx ; Divides one no. by another
cmp dx,00h ; Compares the remainder with zero

Alva‟s Institute of Engineering & Technology, Moodbidri 23


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

je lcm1
pop dx
pop ax
add ax,nums ; If the remainder is not zero,
jnc skip ; take the next multiple of the
inc dx ; dividend and again try to
skip: jmp back ; divide it by the divisor till the
; remainder becomes zero
lcm1: pop lcm+2 ; When the remainder is zero,
pop lcm ; the dividend value is the LCM
int 3
align 16
end start
NOTE: The LCM of 10 and 48 is 240 = F0h

10. C) ALP TO FIND HCF AND LCM OF TWO 8-BIT NUMBERS


.model small
.data
num1 dw 0010
num2 dw 0048
hcf dw ?
lcm dw ?
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov ax,num1
mov bx,num2
loop1: cmp ax,bx ; Compares the given two words
jnc nxchg ; If the minuend is less than subtrahend
xchg ax,bx ; then exchange the two words
nxchg: sub ax,bx ; Subtracts higher no. by lower no.
jnz loop1 ; If the result is zero then that no. is the HCF
mov hcf,bx ; Stores the HCF or GCD

mov ax,num1 ; Finds LCM by using the HCF


mul [num2]
div bx
mov lcm,ax
int 3
align 16
end start
NOTE: The above HCF program can be used to find LCM by using the relation
(Num1*Num2) 10 * 48
= LCM Ex: = 240 = F0h
HCF 2

Alva‟s Institute of Engineering & Technology, Moodbidri 24


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

10. D) ALP TO FIND FACTORIAL OF A GIVEN 8 BIT NUMBER BY USING RECURSIVE METHOD
(USING PROCEDURE)
model small
.data
num dw 0005
prod dw 0001
.code
start: mov ax, @data
mov ds, ax ; Initializes DS
mov ax, num
mov dx, 0000
call fact ; Calls procedure fact
mov prod+2,dx ; Stores the higher word factorial of a given no.
jmp final

fact proc near ; Start of the procedure


cmp ax,0001 ; Compares the given no. with 01
jbe last
push ax
dec ax
call fact ; Call procedure recursively
mov ax, prod
pop bx
mul bx ; Finds the factorial of a given no
mov prod, ax ; Stores the factorial in prod memory
last: ret
fact endp ; End of the procedure
final: int 3
align 16
end start
NOTE: The above program finds the factorial of a number which is in the range 0 to 9.

11. A) ALP TO COUNT THE NUMBER OF POSITIVE AND NEGATIVE NUMBERS IN A GIVEN ARRAY OF N
NUMBERS
.model small
.data
nums dw 1234h,4cedh,08fa9h,0de34h,0abcdh,0aaaah,3333h
len equ ($-nums)/2
pos db 01 dup(0)
negt db 01 dup(0)
.code
start: mov ax,@data
mov ds,ax ; DS intilization

mov cx,len
mov si,00
rpt: mov ax,nums[si]

Alva‟s Institute of Engineering & Technology, Moodbidri 25


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

rol ax,1 ; Rotate left


jc inc_neg
inc pos
jmp ovr ; Unconditional jump
inc_neg: inc negt
ovr: inc si
inc si
loop rpt
int 3
align 16
end start

11. B) ALP TO COUNT THE NUMBER OF ODD AND EVEN NUMBERS IN A GIVEN ARRAY OF N NUMBERS
.model small
.data
nums dw 123fh,4cefh,8fa7h,0de34h,0abcbh,0aaaah,3333h
len equ ($-nums)/2
evn db 01 dup(0)
odd db 01 dup(0)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov cx,len
mov si,00
rpt: mov ax,nums[si]
ror ax,1 ; Rotate right
jc inc_odd
inc evn
jmp ovr
inc_odd: inc odd
ovr: inc si
inc si
loop rpt
int 3
align 16
end start

11. C) ALP TO COUNT LOGICAL 1‟S AND 0‟S IN A GIVEN DATA


.model small
.data
nums dw 00ffh
len equ 16
zero db 01 dup(0)
one db 01 dup(0)
.code
start: mov ax,@data

Alva‟s Institute of Engineering & Technology, Moodbidri 26


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov ds,ax ; Initializes DS


mov cx,len
mov ax,nums
rpt: rol ax,1 ; Rotate left
jc inc_one
inc zero
jmp ovr ; Unconditional jump
inc_one: inc one

ovr: loop rpt


int 3
align 16
end start

11. D) ALP TO CHECK WHETHER THE GIVEN NUMBER IS 2 OUT OF 5 CODE OR NOT
.model small
.data
num db 18h
cnt1 equ 03h
cnt2 equ 05h
res db 3 dup(?)
.code
start: mov ax, @data
mov ds,ax ; Initializes DS
mov al,num
mov cx,cnt1
again: rol al,01h ; Checks for 3 MSB bits
jc no
loop again
mov cx,cnt2
mov bl,00h
back: rol al,01h
jnc jpnxt ; Checks for next 5 bits – Jump on not carry
inc bl
jpnxt: loop back
cmp bl,02h
jnz no ; Jump on not zero
mov res,'y'
mov res+1,'e'
mov res+2,'s'
jmp ovr
no: mov res,'n'
mov res+1,'o'
ovr: int 3
align 16
end start
NOTE: For a 2 out of 5 code, the first 3 MSB‟S must be zero and in the remaining 5 bits 2 bits must be one.

Alva‟s Institute of Engineering & Technology, Moodbidri 27


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

11. E) i) ALP TO CHECK WHETHER THE GIVEN 8 BIT DATA IS BIT WISE PALINDROME OR NOT
.model small
.data
pali db 0a5h
rslt db 3 dup(20h)
.code
start : mov ax,@data
mov ds,ax ; Initializes DS

mov al,pali
mov bl,al
and al,81h
jnp no ; Jump on not Parity/Parity odd

mov al,bl
and al,42h
jnp no

mov al,bl
and al,24h
jnp no

mov al,bl
and al,18h
jnp no

mov rslt,'y'
mov rslt+1,'e'
mov rslt+2,'s'
jmp ovr
no: mov rslt,'n'
mov rslt+1,'o'
ovr int 3
align 16
end start

11. E) ii) ALP TO CHECK WHETHER THE GIVEN 16 BIT DATA IS BIT WISE PALINDROME OR NOT
.model small
.data
num dw 0a5a5h
rslt db 3 dup(20h)
len equ 16
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

Alva‟s Institute of Engineering & Technology, Moodbidri 28


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov ax,num
mov bx,ax
mov cx,len
back: rcr ax,01 ; Rotate through Carry right
rcl dx,01 ; Rotate through Carry left
loop back
cmp bx,dx ; Compare
jz yes
no: mov rslt,‟N‟
mov rslt+1,‟O‟
jmp ovr
yes: mov rslt,‟Y‟
mov rslt+1,‟E‟
mov rslt+2,‟S‟
ovr: int 3
align 16
end start

11. F) ALP TO CHECK WHETHER THE GIVEN 8/16 BIT DATA IS NIBBLE WISE PALINDROME OR NOT
.model small
.data
num db '1221'
len equ ($-num)
len1 equ len/2
rslt db 3 dup(20h)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov si,00
mov cx,len1
mov bx,len-1
rpt: mov al,num[si]
cmp al,num[bx]
jz nxt1
jmp no

nxt1: inc si
dec bx
loop rpt

yes: mov rslt,'y'


mov rslt+1,'e'
mov rslt+2,'s'
jmp ovr
no: mov rslt,'n'
mov rslt+1,'o'

Alva‟s Institute of Engineering & Technology, Moodbidri 29


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

ovr: int 3
align 16
end start
NOTE: The data should be string of hex numbers and data should not be terminated with ‟h‟

12. A) ALP TO ADD „N‟ 16 BIT NUMBERS STORED IN CONSECUTIVE MEMORY LOCATIONS
.model small
.data
nums dw 1111h, 2222h, 0bbbbh, 0ffffh
len equ ($-nums)/2
rslt dw 2 dup(?)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov cx,len ; No. of words to be added


mov ax,00
mov si,00
mov dx,00
rpt: add ax, nums[si]
jnc skip
inc dx
skip: inc si ; Points to
inc si ; the next no.
loop rpt
mov rslt, ax ; Stores the lower word in rslt.
mov rslt+2,dx ; Stores the higher word in rslt+2.
int 3
align 16
end start

12. B) ALP TO FIND SMALLEST / LARGEST NUMBER IN A GIVEN ARRAY


.model small
.data
nums dw 2222h,5555h,3333h,0AAAAh
len equ ($-nums)/2
res dw ?
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov si,offset nums


mov cx,(len-1)
mov ax,[si]

back: inc si
inc si

Alva‟s Institute of Engineering & Technology, Moodbidri 30


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

cmp ax,[si]
jc skip ; To find largest no.use jnc skip
mov ax,[si]
skip: loop back
mov res,ax
int 3
align 16
end start

12. C) ALP TO SORT GIVEN NUMBERS IN ASCENDING/DESCENDING ORDER (BUBBLE SORT)


.model small
.data
num dw 0ffffh,0aaaah,5555h,6666h,4444h,1111h,0cccch,3333h
n equ ($-num)/2
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov cl,n-1 ; No of passes


nxtpas: mov ch,cl ; No of comparisons
lea si,num

nxtcmp: mov ax,[si]


cmp ax,[si+2]
jc noxchg ; To arrange in descending order use jnc noxchg
xchg ax,[si+2]
mov [si],ax

noxchg: inc si
inc si
dec ch
jnz nxtcmp

dec cl
jnz nxtpas
int 3
align 16
end start

13. A) ALP TO MOVE STRING FROM SOURCE TO DESTINATION


.model small
.data
nameb db 'THIS IS PANNA, LEARNING 8086'
cnt equ ($-nameb) ; Finds the length of the string

Alva‟s Institute of Engineering & Technology, Moodbidri 31


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

namea db cnt dup(0)


.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov es,ax ; Initializes ES

cld ; Clears DF
lea si,nameb
lea di,namea
mov cx,cnt
rep movsb ; Transfers the string from src to dst
int 3
align 16
end start

NOTE: 1) when we use string instructions in the program, along with the data segment (DS) extra segment (ES) should be
initialized.
2) If directional flag DF = 0, the pointers are incremented automatically, and
if DF = 1, the pointers are decremented automatically.
3) Rep is a prefix which is written before one of the string instructions. This rep prefix is a string operator which
assumes that, the counter is specified in CX register, it decrements CX by 1 and if it is not equal to zero then it repeats the string
instructions which are followed by it.

13. B) ALP TO REVERSE A GIVEN STRING


.model small
.data
strg1 db „PANNA‟
len equ ($-str1)
space db 5 dup( ) ; Leaves space b/w strg1 and strg2
strg2 db len dup( )
.code
start : mov ax,@data
mov ds,ax ; Initializes DS

lea si,strg1
add si,len-1 ; Points SI to end of the strg1
lea di,strg2 ; Points DI to starting of the strg 2
mov cx,len ; Sets counter with no. of chars in the str1

back: mov al,[si] ; Reverses the strg1 and stores in strg2


mov [di],al
dec si
inc di
loop back
int 3
align 16
end start

Alva‟s Institute of Engineering & Technology, Moodbidri 32


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

13. C) ALP TO SEARCH A CHARACTER IN A GIVEN STRING


.model small
.data
strg db „PRASANNA‟
len equ ($-strg)
char db „S‟
res db 7 dup (0)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
mov es,ax ; Initializes ES

mov cx,len ; Initializes the counter


lea di, strg ; String should be pointed to DI
mov al,char ; Charcter to be searched must be in AL
cld ; Scans from top to bottom
repne scasb ; Repeats scanning until charcters
; are equal or count becomes zero
je found

mov res,‟N‟
mov res+1,‟O‟
mov res+2,‟T‟
found: mov res+3,‟F‟
mov res+4,‟O‟
mov res+5,‟U‟
mov res+6,‟N‟
mov res+7,‟D‟
int 3
align 16
end start

13. D) ALP TO CHECK WHETHER A GIVEN STRING IS PALINDROME OR NOT


.model small
.data
num db 'malayalam'
len equ ($-num)
len1 equ len/2
rslt db 3 dup(20h)
.code
start: mov ax,@data
mov ds,ax ; Initializes DS

mov si,00
mov cx,len1
mov bx,len-1

Alva‟s Institute of Engineering & Technology, Moodbidri 33


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

rpt : mov al,num[si]


cmp al,num[bx]
jz nxt1
jmp no

nxt1: inc si
dec bx
loop rpt

yes: mov rslt,'y' ; Note : 1. jae = jnb = jc


mov rslt+1,'e' ; 2. jbe = jnd
mov rslt+2,'s' ; 3. jb = jnae = jc
jmp ovr ; 4. ja = jnbe

no: mov rslt,'n'


mov rslt+1,'o'
ovr: int 3
align 16
end start
By: MAHESH PRASANNA K.

DEPT. OF E & C, AIET.


********************************************************************************************************
DOS FUNCTION REQUESTS OF INT 21H

1. CHARACTER INPUT WITH ECHO: (READ) FUNCTION 01H


Reads a character from the standard I/P device (usually the KB) and echoes it to the standard O/P device (usually the
display screen), or waits until a character is available. If the returned value is 0, the character is an extended ASCII character. It is
read by invoking this function request once again.
Invoked with : Register AH = 01H
Returns : Register AL = character Input (ASCII code)

2. DISPLAY CHARACTER: (WRITE) FUNCTION 02H


Displays a character at the standard O/P device (usually the display screen).
Invoked with : Register AH = 02H
Register DL = ASCII code for the character to be displayed
Returns : Nothing

3. DISPLAY CHARACTER STRING: FUNCTION 09H


Displays a string of characters at the standard O/P device. The string must be terminated with the character $, which is
not displayed. Output may be redirected.
Invoked with : Register AH = 09H
Register pair DS: DX = segment: offset of string
Returns : Nothing

Alva‟s Institute of Engineering & Technology, Moodbidri 34


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

4. BUFFERED INPUT: FUNCTION 0AH


Reads string of characters from the standard input device, echoes the characters to the standard output device, and
places the characters into a buffer. Input may be redirected.
Invoked with : Register AH = 0AH
Register pair DS: DX = segment: offset of buffer
Returns : Nothing (data placed in buffer)

5. GET DATE: FUNCTION 2AH


Obtains the month, year, day and day of the week as maintained by DOS.
Invoked with : Register AH = 2AH
Returns : Register AL = day of the week (0 through 6, where 0=Sunday,1=Monday, etc.)
Register CX = year (1980 through 2099)
Register DH = month (1 through 12)
Register DL = day (1 through 31)

6. CREATE FILE: FUNCTION 3CH


Creates a new file in the specified or default directory on the specified or the default disc drive. If the file already
exists, it is truncated to zero length. The file is opened for read/write access.
Invoked with : Register AH = 3CH
Register CX = file attributes of the new file as follows:
Bit(s) Significance (if set)
0 read only
1 hidden
2 system
3 volume label
4 reserved(0)
5 archive
6-15 reserved(0)
Register pair DS: DX = segment: offset of ASCII string containing the drive, directory
path and file name.
Returns : If function successful, If function unsuccessful
Carry flag = clear Carry flag = set
Register AX = file handle of the new file Register AX = error code

7. OPEN FILE: FUNCTION 3DH


Opens the specified file in the specified or default directory on the specified or default disk drive. A file handle is
returned which can be used when reading and writing the file.
Invoked with : Register AH = 3DH
Register AL = code indicating mode of access:
Bit(s) Significance (if set)
0-2 access mode

Alva‟s Institute of Engineering & Technology, Moodbidri 35


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

000 = read access


001 = write access
010 = read/write access
3 reserved (0)
4-6 sharing mode
000 = compatibility mode
001 = deny all
010 = deny write
011 = deny read
100 = deny none
7 inheritance flag
0 = child process inherits handle
1 = child doesn‟t inherits handle
Register pair DS: DX = segment: offset of ASCII string containing the drive, directory
path and file name.
Returns : If function successful If function unsuccessful
Carry flag = clear Carry flag = set
Register AX = file handle of the opened file Register AX = error code

8. CLOSE FILE: FUNCTION 3EH


Closes a file that was opened, flushes all internal buffers associated with the file to disk, and updates the file‟s
directory.
Invoked with : Register AH = 3EH
Register BX = file handle returned by the Create File(3CH) or Open File(3DH) function
Request
Returns : If function successful If function unsuccessful
Carry flag = clear Carry flag = set
Register AX = error code

9. READ FILE OR DEVICE: FUNCTION 3FH


Reads information from an opened file or device into a specified memory area (buffer).
Invoked with : Register AH = 3FH
Register BX = file handle returned by the Create File(3CH) or Open File(3DH)
Function request
Register CX = number of bytes to read
Register pair DS: DX = segment: offset of buffer

Returns : If function successful If function unsuccessful


Carry flag = clear Carry flag = set
Register AX = bytes transferred Register AX = error code

Alva‟s Institute of Engineering & Technology, Moodbidri 36


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

10. WRITE FILE OR DEVICE: FUNCTION 40H


Writes information to an opened file or device from a specified buffer.
Invoked with : Register AH = 40H
Register BX = file handle returned by the Create File(3CH) or Open File(3DH) function
request
Register CX = number of bytes to write
Register pair DS: DX = segment: offset of buffer

Returns : If function successful If function unsuccessful


Carry flag = clear Carry flag = set
Register AX = bytes transferred Register AX = error code

11. TERMINATE PROCESS: FUNCTION 4CH


Terminates the current process, returns control either to the parent process or DOS
Invoked with : Register AH = 4CH
Register AL = return code
Returns : Nothing

TASM COMMANDS:

C:\ tasm > edit filename.asm


C:\ tasm > tasm filename.asm
C:\ tasm > tlink filename.obj
C:\ tasm > debug filename.exe

debugger command prompt

After the debugger command prompt the following commands are used;

a – assemble
d – dump (to view the contents of the data memory )
g – go (to execute the entire program at a time )
u – unassemble
t – trace (to execute the program in single step )
r – register (to see the contents of the register )
q – quit
? – to view all the options

By: MAHESH PRASANNA K.


DEPT. OF E & C, AIET.
********************************************************************************************************

Alva‟s Institute of Engineering & Technology, Moodbidri 37


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

14. A) ALP TO DISPLAY A STRING OF CHARACTERS ON CONSOLE


.model small
.data
disp db‟do u think I am joking $‟
.code
start: mov ax,@data
mov ds,ax ; Initializes the DS

mov dx,offset disp ; Points DX to the string to be displayed


mov ah,09h
int 21h
mov ah,4ch ; Terminates the program
int 21h
end start

14. B) ALP TO READ A CHARACTER FROM KEY BOARD.


. model small
. data
msg db „enter a key from the keyboard$‟
num db ?
. code
start: mov ax,@data
mov ds,ax ; Initializes the DS

mov dx, offset msg ; Displays the message


mov ah,09h
int 21h

mov ah,01h ; Allows the user to enter


int 21h ; a key from the keyboard
mov num,al
mov ah,4ch ; Terminates the program
int 21h
end start

14. C) ALP TO OBTAIN BUFFERED KEYBOARD INPUT


. model small
.data
buff db 10 dup(20h)
.code
start: mov ax,@data
mov ds,ax ; Initializes the DS

mov dx,offset buff


mov ah,0ah
int 21h

Alva‟s Institute of Engineering & Technology, Moodbidri 38


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov ah,4ch ; Terminates the program


int 21h
end start

14. D) i) ALP TO CREATE A NEW FILE


. model small
.data
fl_name db „txt4.asm‟
.code
start: mov ax,@data
mov ds,ax ; Initializes the DS

mov cx,0 ; Normal mode


mov dx,offset fl_name
mov ah, 3ch
int 21h
mov ah,4ch ; Terminates the program
int 21h
end start

14. D) ii) ALP TO CREATE A NEW FILE, WRITE ON TO IT AND READ FROM THE FILE
.model small
.data
fl_name db “new.txt”,0
fl_hdl dw ?
writeme db “Hello! This is a test! Has it worked? Thanks $”
len equ ($-writeme)
msg db “ creates a file new.txt in the current directory$”
buffer db len dup (20h)
.code
start: mov ax,@data
mov ds,ax ; Initializes the DS

mov dx,offset msg ; Displays the msg


mov ah,09h
int 21h

mov cx,0 ; normal mode


mov dx,offset fl_name
mov ah,3ch ; to create file
int 21h

mov dx,offset fl_name ; to open file


mov al,2 ; read and write mode
mov ah,3dh
int 21h

Alva‟s Institute of Engineering & Technology, Moodbidri 39


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov fl_hdl,ax
mov dx,offset writeme ; to write msg
mov bx,fl_hdl
mov cx,len
mov ah,40h
int 21h

mov bx,fl_hdl ; to close the file


mov ah,3eh
int 21h

mov dx,offset fl_name


mov al,2 ; to open the file in read & write mode
mov ah,3dh
int 21h

mov fl_hdl,ax
mov dx, offset buffer ; to read a file into buffer
mov bx,fl_hdl ; read and write mode
mov cx,len
mov ah,3fh
int 21h

mov fl_hdl,ax ; to close the file


mov bx,fl_hdl
mov ah,3eh
int 21h

mov dx,offset buffer ; testing of read operation


mov ah,09h
int 21h
mov ah,4ch ; Terminates the program
int 21h
end start

14. E) ALP TO READ THE SYSTEM DATE,DAY AND MONTH AND DISPLAY ON CONSOLE
.model small
.data
yr1 dw ?
mt1 db ?
dt1 db ?
wk1 db ?
days db “sun$mon$tue$wed$thu$fri$sat$”
months db “jan$feb$mar$apr$may$jun$jul$aug$sep$oct$nov$dec$”
.code
start : mov ax,@data
mov ds,ax

Alva‟s Institute of Engineering & Technology, Moodbidri 40


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

mov ah,2ah ; Gets the system date, month, day


int 21h
mov yr1,cx ; year (1980-2099)
mov mt1,dh ; month (1-12)
mov dt1,dl ; date (1-31)
mov wk1,al ; day (0-sun,1-mon,………)

mov al,dt1 ; BINARY to BCD conversion


mov ah, 00
mov dl,0ah
div dl
or ax,3030h
mov bl,al
mov bh,ah

mov dl,bl
mov ah,02
int 21h

mov dl,bh
mov ah,02
int 21h

mov dx,offset months ; to display month


mov al, mt1
dec al
mov bl,04
mul bl

add dx,ax
mov ah,09
int 21h

mov dx,offset days ; to display day


mov al, wk1
mov bl,04
mul bl

add dx,ax
mov ah,09
int 21h

mov ah ,4ch ; Terminates the program


int 21h
align 16
end start

Alva‟s Institute of Engineering & Technology, Moodbidri 41


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

Delay Calculations:
Instructions Clock Cycles
MOV CX, N 4 = Co
Delay: NOP 3
NOP 3
LOOP Delay 17 or 5.

If 8086 clock frequency is 5 MHz, then the time for each clock cycle is, t = 1/5MHz=0.2 sec.

Now, suppose that you want to create a delay of 1msec. (or Td = 1000 sec.), with a delay loop, 1000/0.2 = 5000 processor
cycles are necessary to produce 1msec delay.
ie, CT=5000 we have, CT = Co + N (CL) – 12

The only instruction which executes just once is MOV CX, N; which takes 4 clock cycles (Co=4).

For the delay loop, NOPs require 6 cycles. The LOOP instruction requires 17 clock cycles if it does the jump back to Delay, else
5 clock cycles.
CL = 17 + 6
Loop Two NOPs.

ie, Total Cycles CT=Co + N (CL) – 12.

CT – Co + 12 5000 – 4 + 12
N = --------------------- = ----------------- = 218 = DA (Hexa-Decimal).
CL 23

We can divide the procedure to find the delay into following convenient steps:
Step 1: Determine the exact delay required. Let‟s call it as Td.
Step 2: Choose the instructions to be used in delay loop. Care must be taken not to use instructions or registers that
affect the main program calling the delay procedure.
Step 3: Determine the number of clock cycles needed to execute each instruction chosen. Also calculate the total
number of clock cycles required to execute the loop once. Let‟s call it „CL‟.
Step 4: Find t, the time required for one clock period. i.e. t = 1/f.
Step 5: Find N (approximately), number of times the loop has to be executed to generate Td delay using;

Td
N=
CL * t

Alva‟s Institute of Engineering & Technology, Moodbidri 42


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

15. KEYBOARD INTERFACE

The rows are connected to an output port and the columns are connected to an input port. If no key has been pressed,
reading the input port will yields 0s for all columns since they are all connected to ground. If all the rows are high and a key is
pressed, one of the columns will have 1 since the key pressed provides the path to high. It is the function of the microprocessor to
scan the keyboard continuously to detect and identify the key pressed.

Label on Hex code Label on Hex code


the keytop the key top
0 0 - 0C
1 1 X 0D
2 2 / 0E
3 3 % 0F
4 4 AC 10
5 5 CE 11
6 6 CHK 12
7 7 = 13
8 8 MC 14
9 9 MR 15
. 0A M 16
+ 0B M+ 17

Process of identifying the key pressed:

To detect a pressed key, the microprocessor set high all rows by providing 1 to the output latch, then it reads the
columns. If the data read from the columns is PA0-PA7 = 00000000, no key has been pressed and process continues until a key
press is detected.
If one of the column bits has a high, this means that a key press has occurred.
For example, if PA0-PA7 = 00001000, this means that a key in the PA4 column has been pressed.

Alva‟s Institute of Engineering & Technology, Moodbidri 43


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

After a key press is detected, the microprocessor will go through the process of identifying the key. Now
microprocessor sets each row to ground then it reads the columns. If the data read is all 0s, no key in that row is activated and
the process is moved to next row. It grounds the next row, reads the columns, and checks for any 1. This process continues until
the row is identified. After identification of the row in which the key has been pressed, the next task is to find out which column
the pressed key belongs to.

To identify the key press, it rotates the column bits, one bit at a time, into the carry flag and checks to see if it is high.
Upon finding the 1, it pulls out the ASCII code for that key from the look-up table; otherwise, it increments the pointer to point to
the next element of the look-up table.
; ****************************************************************************************** ;
; This program is demonstration program for using KeyBoard Interface ;
; This program uses DOS Interrupts ;
; ****************************************************************************************** ;
.MODEL SMALL ; Specify the model for the executable. Must for every program.
.STACK 5000H
.DATA ; Any data declarations here.
Message1 DB 'DEMONSTRATION PROGRAM FOR KEYBOARD INTERFACE',13,10,'$'
Message2 DB 'This program will display the key you pressed on the Interface.',13,10,'$'
Message3 DB 'This program is running...',13,10,'Press any key to EXIT.',13,10,'$'
Message4 DB 13,'The Key You Pressed is : ','$'
Keys DB '0 1 2 3 4 5 6 7 8 9 . + - X / % ACCECK= MCMRM M+','$'
Show DB '01','$ '
;; NOTE: The following data declarations are common for every program. The values of CR, PA, PB and PC will vary from
;; PC to PC. The user need to modify the values of CR, PA, PB, PC for assembling the program.
CR EQU 0cd03h
PA EQU 0cd00h
PB EQU 0cd01h
PC EQU 0cd02h
.CODE ; Start your coding here.
MOV AX,@DATA ; Initialize all segment registers as needed here.
MOV DS, AX
MOV AH, 9h ; Display the message line1.
MOV DX, OFFSET Message1
INT 21h
MOV AH, 9h ; Display the message line2.
MOV DX, OFFSET Message2
INT 21h
MOV AH, 9h ; Display the message line3.
MOV DX, OFFSET Message3
INT 21h

MOV AX, 92h ; Initialize Port A - Input, CU & CL – Output.


MOV DX, CR
OUT DX, AX ; Write to Control Register.

Alva‟s Institute of Engineering & Technology, Moodbidri 44


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

GETKEY: MOV BH, 1h ; Scan Lines.


MOV BL, 00h ; Initialize a counter. It contains the no of the Key.

SCANLINES: MOV AL, BH


MOV DX, PC ; Send Line Number to Port CL.
OUT DX, AL
MOV DX, PA ; Read from Port A.
IN AL, DX
MOV CH, AL ; CH has the value indicating the key pressed.
MOV AL, 00H

CHECK: MOV CL, CH ; Initialize the counter & repeatedly check which key was selected.
MOV CL, CH
AND CL, 01h ; CH is shifted to right.
CMP CL, 01h
JZ DISPPLAY ; If Equal Come out.
INC BL
SHR CH, 01h ; CH = CH >> 1.
INC AL
CMP AL, 08h ; All bits are compared
JNZ CHECK
; Go back for next scan line.
SHL BH, 01h ; Move to next scan line.
CMP BH, 10h
JNZ SCANLINES ; Repeat the SCAN Lines Loop (4 times).
JMP LOOPOUT

DISPPLAY: ; Display the selected key.


MOV AH, 9h ; Display the message line3.
MOV DX, OFFSET Message4
INT 21h

MOV AX, 0000h


MOV AL, BL
MOV BL, 02h
MUL BL
MOV BX, AX
MOV DI, OFFSET Show
MOV AL, Keys[BX]
MOV Show[0h], AL
MOV AL, Keys[BX + 1h]

Alva‟s Institute of Engineering & Technology, Moodbidri 45


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

MOV Show[1h], AL
MOV AH, 9h ; Display the character pressed.
MOV DX, OFFSET Show
INT 21h
MOV CX, 0FFFFh

DELAY: MOV AX, 0FFh


DELAY1: DEC AX
JNZ DELAY1
LOOP DELAY

LOOPOUT: MOV AH, 01h


INT 16h ; Get the Key.
JZ GETKEY ; Check for the key.

MOV AH, 4Ch ; Exit the program safely.


INT 21h
END ; This is the end of your program.

16. SEVEN SEGMENT INTERFACE


The hardware uses four shift register ICs 74164. 74164 is an 8-bit serial in-parallel out shift register with
asynchronous reset and two input pins. It requires 8 clock cycles at “CLK” pin to shift the serial data from input to 8 parallel
outputs. After 8 shifts, the first serial bit will be in output QH, and only now the data at output is valid. To cascade more 74164
shift register IC need to connect the last output QH to the input of second shift register.
The output is connected to the cathode of the LEDs in the 7 segment display and thus common anode displays are used.
The anode is connected to +Vcc..The last output of the first sift register is connected to input of the 2 nd shift register and the last
output o f 2nd shift register to input of 3rd and so on. Thus the shift register are serial in parallel out and they are connected to
displays, in such a way that output 0A is connected to display segment „a‟ and 0B to „b‟ and so on up to 0H; through 330 ohm
resistors.
The shifting of data bit takes place for each clock cycle. 7404 IC used provides isolation and the interface board gets
5V through port bit.
Pin 1 is used as data pin and pin 2 is used as other input to Vcc. The clock signal is generated at a port bit which will
be connected to the clock of the shift register.

PB0 is used for data bit; and PC0 for clock through which a falling edge has to be sent.

The microprocessor stores the display information in a RAM. Each time a display has to be updated the
microprocessor fetches all bytes one by one from RAM and outputs corresponding display codes serially that is bit by bit to
display. Hexadecimal code is stores in the RAM. The code conversion from hexa to 7 segment is done just before the display is
updated.

The 7 segment display is used as a numerical indicator on many types of test equipment. It is an assembly of light
emitting diodes which can be powered individually. There are two important types of 7-segment LED display.
In a common cathode display, the cathodes of all the LEDs are joined together and the individual segments are illuminated by
HIGH voltages.
In a common anode display, the anodes of all the LEDs are joined together and the individual segments are illuminated by
connecting to a LOW voltage.

Display code

Alva‟s Institute of Engineering & Technology, Moodbidri 46


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

Since the outputs of shift registers are connected to cathode sides of displays, low input must be given to segments for
making them glow and high inputs for making them blank. Each display has 8 segments (a, b, c, d, e, f, g, h) as shown. For
displaying any character the corresponding segment must be given low inputs.

The one shown above is a common anode display since all anodes are joined together and go to the positive supply.
The cathodes are connected individually to zero volts. Resistors must be placed in series with each diode to limit the current
through each diode to a safe value. The d.p represents a decimal point.

The following table shows how to form characters: '0' means that pin is connected to ground. '1' means that pin is
connected to Vcc.

STRING: HELP
d.p g f e d c b a

1 0 0 0 1 1 0 0 ---- P (8CH)

1 1 0 0 0 1 1 1 ---- L (C7H)

1 0 0 0 0 1 1 0 ---- E (86H)

1 0 0 0 1 0 0 1 ---- H (89H)

74164 is an 8-bit SIPO Shift Register. Instead of a single-serial input, an AND gate combines inputs DA and DB to produce the
serial input. When clock and DB inputs are high, output of AND gate which is the actual serial Input for the shift register is
nothing but the input DA which is connected to the Least Significant Bit of port B (PB0). PCo, Least Significant Bit of port C has
been internally connected to the clock i/p of all 74164 IC‟s.

Alva‟s Institute of Engineering & Technology, Moodbidri 47


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

; ****************************************************************************************** ;
; This program is demonstration program for using Seven Segment Display Interface. ;
; This program uses DOS Interrupts. ;
; ****************************************************************************************** ;
.MODEL SMALL ; Specify the model for the executable. Must for every program.
.STACK 5000H
.DATA ; Any data declarations here.
Message1 DB „DEMONSTRATION PROGRAM FOR SEVEN SEGMENT DISPLAY',13,10,'$'
Message2 DB „Check the Message < HELP> on Seven Segment Display',13,10,'$'
Message3 DB „This program is running...', 13,10,'Press any key to EXIT.',13,10,'$'
DisplayData DB 089h, 086h, 0C7h, 08Ch
CR EQU 0cd03H
PA EQU 0cd00H
PB EQU 0cd01H
PC EQU 0cd02H
.CODE ; Start your coding here.
MOV AX, @DATA ; Initialize all segment registers as needed here.
MOV DS, AX
MOV AH, 9h ; Display the message line1.
MOV DX, OFFSET Message1
INT 21h

Alva‟s Institute of Engineering & Technology, Moodbidri 48


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

MOV AH, 9h ; Display the message line2.


MOV DX, OFFSET Message2
INT 21h
MOV AH, 9h ; Display the message line3.
MOV DX, OFFSET Message3
INT 21h

MOV AL, 80h ; Send the control word


MOV DX, CR
OUT DX, AL
GETKEY: MOV BX, 0000h
LOOP1: MOV AL, BL ; Display the characters 4 at a time.
AND AL, 03h
CMP AL, 00H
JNZ NO_DELAY
MOV CX, 0FFFFh
DELAY: MOV AX, 0fFFFh
DELAY1: DEC AX
JNZ DELAY1
LOOP DELAY
NO_DELAY: MOV CL, 00h
MOV CH, DisplayData[BX]
LOOP2: MOV AH, 01h
INT 16h ; Get the Key
JNZ END_PROGRAM
; MOV CL, 01
MOV AH, CH
AND AH, 80h
CMP AH, 00h
JNZ CONTROL
MOV DX, PB
MOV AL, 00h
OUT DX, AL
JMP END_CONTROL
CONTROL: MOV DX, PB
MOV AL, 01h
OUT DX, AL
END_CONTROL: MOV DX, PC
MOV AL, 01h
OUT DX, AL
MOV DX, PC

Alva‟s Institute of Engineering & Technology, Moodbidri 49


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

MOV AL, 00h


OUT DX, AL
SHL CH, 1
INC CL
CMP CL, 08h
JNZ LOOP2 ; LOOP2 Repeats from here.
INC BX
CMP BX, 20
JNZ LOOP1 ; LOOP1 Repeats from here.
MOV AH, 01h
INT 16h ; Get the Key
JZ GETKEY
END_PROGRAM: MOV AH, 4ch ; Exit the program safely.
INT 21h
END ; This is the end of your program.

17. LOGIC CONTROLLER INTERFACE


Logic controllers find extensive application in industries for the programming of processes. The nature of control
would range from a simple ON/OFF type of control for complex systems implementing sophisticated control algorithms while
accepting multiple inputs and actuating multiple outputs. A controller would typically, accept a number of inputs from
transducers like sensors/limit switches, key inputs etc., perform a sequence of logical and arithmetic operations on them and use
the result to maintain the process within specified safe operating conditions while providing information on the status of the
process at any instant of time. The logic controller interface consists essentially of two 8 bit ports, an input and an outpu t port.
The inputs and outputs are connected to the user systems. The logic state of each input and output is indicated by LEDs and all
signals are TTL compatible. The input signals are connected to port B of 82C55A while output lines are driven from port A.
Some of the capabilities of this interface are:
a. Programmable Counter b. Sequential Counter c. Combinational Controller.

Alva‟s Institute of Engineering & Technology, Moodbidri 50


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

; ****************************************************************************************** ;
; This program is demonstration program for using Logic Controller Interface. ;
; This program uses DOS Interrupts. ;
; ****************************************************************************************** ;
.MODEL TINY ; Specify the model for the executable. Must for every program.
.DATA ; Any data declarations here.
CR EQU 0cd03h
PA EQU 0cd00h
PB EQU 0cd01h
PC EQU 0cd02h
Message1 DB „DEMONSTRATION PROGRAM FOR LOGIC CONTROLLER', 13, 10,'$'
Message2 DB „This program will read input in Port B. and outputs', 13,10,'$'
Message3 DB „it‟‟s compliment in Port A.', 13, 10, 13, 10,'$'
Message4 DB „This program is running...', 13,10,'Press any key to EXIT.',13,10,'$'
.STACK
.CODE MOV AX, @DATA ; Start your coding here. Initialize all segment registers as needed.
MOV DS, AX
MOV AH, 9h ; Display the message line1.
MOV DX, OFFSET Message1
INT 21h
MOV AH, 9h ; Display the message line2.
MOV DX, OFFSET Message2
INT 21h
MOV AH, 9h ; Display the message line3.
MOV DX, OFFSET Message3
INT 21h
MOV AH, 9h ; Display the message line4.
MOV DX, OFFSET Message4
INT 21h

MOV AL, 82H ; Initialize A - Output & B-Input Ports.


MOV DX, CR
OUT DX, AL ;Write to Control Register.
GETKEY: MOV DX, PB ; Get Data from Register B.
IN AL, DX
NOT AL ; Compliment it.
MOV DX, PA ; Put Data to Register A.
OUT DX, AL
MOV AH,01h
INT 16h ; Get the Key
JZ GETKEY

Alva‟s Institute of Engineering & Technology, Moodbidri 51


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

MOV AH, 4Ch ; Exit the program safely.


INT 21h
END ; This is the end of your program.

18. STEPPER MOTOR INTERFACE


A stepper motor is a widely used device that translates electrical pulses into mechanical movement. In applications
such as disk drives, dot matrix printers, and robotics, the stepper motor is used for Position control.
Every stepper motor has a permanent magnet rotor (also called the shaft.) surrounded by a stator. The most common
stepper motors have four common stator windings that are pairs with a center-taped common. This type of stepper motor is
commonly referred to as a four-phase stepper motor.
A Stepper motor is stepped from one position to the next by changing the currents through the fields in the motor.
Common step sizes for stepper motors range from 0.9 degrees to 30 degrees.
82C55A is used to provide the drive signals that are used to rotate the armature of the motor in either the right-hand or
left-hand direction.

The power circuit for one winding of the stepper motor is as shown in figure above. It is connected to the port A (PA0)
of 82C55A. Similar circuits are connected to the remaining lower bits of port A (PA1, PA2, PA3). One winding is energized at a
time. The coils are turned ON/OFF one at a time successively.
The stepper motor showing full-step operation is shown below.
(A) 45-degrees. (B) 135-degrees (C) 225-degrees (D) 315-degrees.

Alva‟s Institute of Engineering & Technology, Moodbidri 52


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

; ********************************************************************************************** ;
; This program is demonstration program for using Stepper Motor Interface. ;
; This program uses DOS Interrupts. ;
; ********************************************************************************************** ;
.MODEL small ; Specify the model for the executable. Must for every program.
.STACK 100h
.DATA ; Any data declarations here.
CR EQU 0cd03H
PA EQU 0cd00H
PB EQU 0cd01H
PC EQU 0cd02H
Message1 DB „DEMONSTRATION PROGRAM FOR STEPPER MOTOR', 13, 10,'$'
Message2 DB 13, 10,'This program is running...', 13,10,'$'
.CODE
MOV AX, @DATA
MOV DS, AX
MOV AH, 9h ; Display the message line1.
MOV DX, OFFSET Message1
INT 21h
MOV AH,9h ; Display the message line3.
MOV DX, OFFSET Message2
MOV AH,9h ; Display the message line1.
MOV DX, OFFSET Message1
INT 21h
MOV AH,9h ;Display the message line3.
MOV DX, OFFSET Message2
INT 21h
again: MOV AH, 01h
INT 16H
JZ s1
MOV AH, 4ch ; EXIT PROGRAM
INT 21h
s1: MOV DX, CR
MOV AL, 80h
OUT DX, AL

MOV AL, 88h


CALL OUT_A
CALL DELAY
MOV AL, 44h

Alva‟s Institute of Engineering & Technology, Moodbidri 53


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

CALL OUT_A
CALL DELAY
MOV AL, 22h
CALL OUT_A
CALL DELAY
MOV AL, 11h
CALL OUT_A
CALL DELAY
JMP again
OUT_A: MOV DX, PA
OUT DX, AL
RET
DELAY: MOV CX, 001FFh
MOV BX, 0FFFFH
D2: MOV AX, 0FFFFh
D1: DEC AX
JNZ D1
DEC CX
JNZ D2
RET
END ; This is the end of your program.
STEPPER MOTER IN STEPS
.MODEL SMALL
.DATA
PA EQU 0cdD00H
PB EQU 0cd01H
PC EQU 0cd02H
CTRL EQU 0cd03H
NSTEP DB 10
.CODE
START: MOV AX, @DATA
MOV DS, AX
MOV AL, 80H
MOV DX, CTRL
OUT DX, AL
MOV BH, NSTEP
MOV AL, 88H
AGAIN1: CALL STEP
ROR AL, 1
DEC BH
JNZ AGAIN1
INT 3

STEP PROC
MOV DX, PA
OUT DX, AL

Alva‟s Institute of Engineering & Technology, Moodbidri 54


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

MOV CX, 0FFFFH


D2: MOV DI, 8FFFH
D1: DEC DI
JNZ D1
LOOP D2
RET
STEP ENDP
END START

19. PRINTER INTERFACE


.MODEL SMALL
.DATA
MSG DB 'ELECTRO SYSTEMS ASSOCIATES PVT LTD', 0AH, 00H
MSG1 DB 'Printer is Busy and not responding', 13, 10,'$'
CR EQU 0a403H
PA EQU 0a400H
PB EQU 0a401H
PC EQU 0a402H
.STACK
.CODE
MOV DX, CR ; 8255 Initialization.
MOV AL, 90H ; Port A i/p
OUT DX, AL ; Port B & Port C o/p.
MOV DX, PC ; Port C for Strobe.
MOV AL, 01H ; Making Strobe line High through PC0.
OUT DX, AL
MOV AX, @DATA ; Set Data segment.
MOV DS, AX
MOV SI, OFFSET MSG ; Load msg offset into SI.

MOV BX, 0FFFFH


L3: MOV DX, PA ; Checking Printer Status for low
IN AL, DX ; through PA7 bit.
AND AL, 80H ; If Status line is high check again.
CMP AL, 80H
JNE L2
DEC BX
JNZ L3
MOV DX, OFFSET MSG1
MOV AH, 02H
INT 21H
JMP EXIT

Alva‟s Institute of Engineering & Technology, Moodbidri 55


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

L2: MOV DX, PB ; Loading Message data into Port B


MOV AL, [SI] ; from SI.
CMP AL, 00H ; Checking for end of message.
JE EXIT ; If yes exit from program.
OUT DX, AL

MOV DX, PC ; Making Strobe line low.


MOV AL, 00H
OUT DX, AL
MOV CX, 07FFH ;Delay depends on the Printer speed.
L1: LOOP L1 ; This can be changed.

MOV DX, PC ; Making Strobe line High.


MOV AL, 01H
OUT DX, AL

INC SI ; Incrementing message offset.


JMP L3

EXIT: MOV AH, 4CH ; Terminate the Program


INT 21H
END
By: MAHESH PRASANNA K.

DEPT. OF E & C, AIET.


********************************************************************************************************
Viva Questions and Answers
1. What is a Microprocessor?
ANS: Microprocessor is a program-controlled device, which fetches the instructions from memory, decodes and executes the
instructions. Most Microprocessors are single- chip devices.
2. What is the difference between 8086 and 8088?
ANS: The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue is 4 byte long in 8088and 6 byte in 8086.
3. What are the functional units in 8086?
ANS: 8086 has two independent functional units because of that the processor speed is more. The Bus interface unit and
Execution unit are the two functional units.
4. What are the flags in 8086?
ANS: In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag,
and Sign flag.
5. What is the Maximum clock frequency in 8086?
ANS: 5 Mhz is the Maximum clock frequency in 8086.
6. What are the various segment registers in 8086?
ANS: Code, Data, Stack, Extra Segment registers in 8086.

Alva‟s Institute of Engineering & Technology, Moodbidri 56


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

7. Logic calculations are done in which type of registers?


ANS: Accumulator is the register in which Arithmetic and Logic calculations are done.
8. How 8086 is faster than 8085?
ANS: Because of pipelining concept. 8086 BIU fetches the next instruction when EU busy in executing the another instruction.
9. What does EU do?
ANS: Execution Unit receives program instruction codes and data from BIU, executes these instructions and store the result in
general registers.
10. Which Segment is used to store interrupt and subroutine return address registers?
ANS: Stack Segment in segment register is used to store interrupt and subroutine return address registers.
11. What does microprocessor speed depend on?
ANS: The processing speed depends on DATA BUS WIDTH.
12. What is the size of data bus and address bus in 8086?
ANS: 8086 has 16-bit data bus and 20- bit address bus.
13. What is the maximum memory addressing capability of 8086?
ANS: The maximum memory capability of 8086 is 1MB.
14. What is flag?
ANS: Flag is a flip-flop used to store the information about the status of a processor and the status of the instruction executed
most recently.
15. Which Flags can be set or reset by the programmer and also used to control the operation of the processor?
ANS: Trace Flag, Interrupt Flag, Direction Flag.
16. In how many modes 8086 can be operated and how?
ANS: 8086 can be operated in 2 modes. They are Minimum mode if MN/MX pin is active high and Maximum mode if MN/MX pin
is ground.
17. What is the difference between min mode and max mode of 8086?
ANS: Minimum mode operation is the least expensive way to operate the 8086 microprocessor because all the control signals for
the memory and I/O are generated by the micro processor. In Maximum mode some of the control signals must be externally
generated. This requires the addition of an external bus controller. It used only when the system contains external coprocessors
such as 8087 arithmetic coprocessor.
18. Which bus controller used in maximum mode of 8086?
ANS: 8288 bus controller is used to provide the signals eliminated from the 8086 by the maximum mode operation.
19. What is stack?
ANS: Stack is a portion of RAM used for saving the content of Program Counter and general purpose registers.
20. Which Stack is used in 8086?
ANS: FIFO (First In First Out) stack is used in 8086.In this type of Stack the first stored information is retrieved first.
21. What is the position of the Stack Pointer after the PUSH instruction?
ANS: The address line is 02 less than the earlier value.
22. What is the position of the Stack Pointer after the POP instruction?
ANS: The address line is 02 greater than the earlier value.
23. What is interrupt?
ANS: Interrupt is a signal send by external device to the processor so as to request the processor to perform a particular work.

Alva‟s Institute of Engineering & Technology, Moodbidri 57


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

24. What are the various interrupts in 8086?


ANS: Maskable interrupts, Non-Maskable interrupts.
25. What is meant by Maskable interrupts?
ANS: An interrupt that can be turned off by the programmer is known as Maskable interrupt.
26. What is Non-Maskable interrupts?
ANS: An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable interrupt.
27. Which interrupts are generally used for critical events?
ANS: Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency, Shut off etc.,
28. Give example for Non-Maskable interrupts?
ANS: Trap is known as Non-Maskable interrupts, which is used in emergency condition.
29. Give examples for Maskable interrupts?
ANS: RST 7.5, RST6.5, RST5.5 are Maskable interrupts. When RST5.5 interrupt is received the processor saves the contents of
the PC register into stack and branches to 2Ch (hexadecimal) address.
When RST6.5 interrupt is received the processor saves the contents of the PC register into stack and branches to 34h
(hexadecimal) address.
When RST7.5 interrupt is received the processor saves the contents of the PC register into stack and branches to 3Ch
(hexadecimal) address.
30. What is SIM and RIM instructions?
ANS: SIM is Set Interrupt Mask. Used to mask the hardware interrupts. RIM is Read Interrupt Mask. Used to check whether the
interrupt is Masked or not.
31. What is macro?
ANS: Macro is a set of instructions that perform a task and all the instructions defined in it is inserted in the program at the
point of usage.
32. What is the difference between Macro and Procedure?
ANS: A procedure is accessed via a CALL instruction and a macro will inserted in the program at the point of execution.
33. What is meant by LATCH?
ANS: Latch is a D- type flip-flop used as a temporary storage device controlled by a timing signal, which can store 0 or 1. The
primary function of a Latch is data storage. It is used in output devices such as LED, to hold the data for display
34. What is a compiler?
ANS: Compiler is used to translate the high-level language program into machine code at a time. It doesn‟t require special
instruction to store in a memory, it stores automatically. The Execution time is less compared to Interpreter.
35. What is the disadvantage of microprocessor?
ANS: It has limitations on the size of data. Most Microprocessor does not support floating-point operations.
36. What is the 82C55A device?
ANS: The 8255A/82C55A interfaces peripheral I/O devices to the microcomputer system bus. It is programmable by the system
software. It has a 3-state bi-directional 8-bit buffer which interfaces the 8255A/82C55A to the system data bus.
37. What kind of input/output interface dose a PPI implement?
ANS: It provides a parallel interface, which includes features such as single-bit, 4-bit, and byte-wide input and output ports;
level-sensitive inputs; latched outputs; strobed inputs or outputs; and strobed bidirectional input/outputs.
38. How many I/O lines are available on the 82C55A?
ANS: 82C55A has a total of 24 I/O lines.

Alva‟s Institute of Engineering & Technology, Moodbidri 58


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

39. Describes the mode 0, mode 1, and mode 2 operations of the 82C55A?
ANS: MODE 0: Simple I/O mode. In this mode, any of the ports A, B, and C can be programmed as input or output. In this mode,
all the bits are out or in.
MODE 1: Ports A and B can be used as input or output ports with handshaking capabilities. Handshaking signals are provided
by the bits of port C.
MODE 2: Port A can be used as a bidirectional I/O port with handshaking capabilities whose signals are provided by port C.
Port B can be used either in simple I/O mode or handshaking mode 1.
40. What is the mode and I/O configuration for ports A, B, and C of an 82C55A after its control register is loaded with 82H?
ANS: If control register is loaded with 82H, then the port B is configured as an input port, port A and port C are configured as
output ports and in mode 0.
41. What are the flags in 8086? - In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag,
Interrupt flag, Direction flag, and Sign flag.
42. What are the various interrupts in 8086? - Maskable interrupts, Non-Maskable interrupts.
43. What is meant by Maskable interrupts? - An interrupt that can be turned off by the programmer is known as Maskable
interrupt.
44. What is Non-Maskable interrupts? - An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable
interrupt.
45. Which interrupts are generally used for critical events? - Non-Maskable interrupts are used in critical events. Such as
Power failure, Emergency, Shut off etc.,
46. Give examples for Maskable interrupts? - RST 7.5, RST6.5, RST5.5 are Maskable interrupts
47. Give example for Non-Maskable interrupts? - Trap is known as Non-Maskable interrupts, which is used in emergency
condition.
48. What is the Maximum clock frequency in 8086? - 5 Mhz is the Maximum clock frequency in 8086.
49. What are the various segment registers in 8086? - Code, Data, Stack, Extra Segment registers in 8086.
50. Which Stack is used in 8086? - FIFO (First In First Out) stack is used in 8086.In this type of Stack the first stored
information is retrieved first.
51. What are the address lines for the software interrupts? –
RST0 RST1 RST2 RST3 RST4 RST5 RST6 RST7
0000H 0008H 0010H 0018H 0020H 0028H 0030H 0038H
52. What are SIM and RIM instructions? - SIM is Set Interrupt Mask. Used to mask the hardware interrupts. RIM is Read
Interrupt Mask. Used to check whether the interrupt is Masked or not.
53. Which is the tool used to connect the user and the computer? - Interpreter is the tool used to connect the user and the tool.
54. What is the position of the Stack Pointer after the PUSH instruction? - The address line is 02 less than the earlier value.
55. What is the position of the Stack Pointer after the POP instruction? - The address line is 02 greater than the earlier value.
56. Logic calculations are done in which type of registers? - Accumulator is the register in which Arithmetic and Logic
calculations are done.
57. What are the different functional units in 8086? - Bus Interface Unit and Execution unit, are the two different functional
units in 8086.
58. Give examples for Micro controller? - Z80, Intel MSC51 &96, Motorola are the best examples of Microcontroller.
59. What is meant by cross-compiler? - A program runs on one machine and executes on another is called as cross-compiler.

Alva‟s Institute of Engineering & Technology, Moodbidri 59


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

60. What are the address lines for the hardware interrupts? –
RST7.5 RST6.5 RST5.5 TRAP
003CH 0034H 002CH 0024H
61. Which Segment is used to store interrupt and subroutine return address registers? - Stack Segment in segment register is
used to store interrupt and subroutine return address registers.
62. Which Flags can be set or reset by the programmer and also used to control the operation of the processor? - Trace Flag,
Interrupt Flag, Direction Flag.
63. What does EU do? - Execution Unit receives program instruction codes and data from BIU, executes these instructions and
store the result in general registers.
64. Which microprocessor accepts the program written for 8086 without any changes? - 8088 is that processor.
65. What is the difference between 8086 and 8088? - The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue is 4
byte long in 8088and 6 byte in 8086.
Some more Viva Questions
1) How many bit 8086 microprocessor is?
2) What is the size of data bus of 8086?
3) What is the size of address bus of 8086?
4) What is the max memory addressing capacity of 8086?
5) Which are the basic parts of 8086?
6) What are the functions of BIU?
7) What are the functions of EU?
8) How many pin IC 8086 is?
9) What IC8086 is?
10) What is the size of instruction queue in 8086?
11) What is the size of instruction queue in 8088?
12) Which are the registers present in 8086?
13) What do you mean by pipelining in 8086?
14) How many 16 bit registers are available in 8086?
15) Specify addressing modes for any instruction?
16) What do you mean by assembler directives?
17) What .model small stands for?
18) What is the supply requirement of 8086?
19) What is the relation between 8086 processor frequency & crystal freq.?
20) Functions of Accumulator or AX register?
21) Functions of BX register?
22) Functions of CX register?
23) Functions of DX register?
24) How Physical address is generated?
25) Which are pointers present in this 8086?
26) Which is by default pointer for CS/ES?
27) How many segments present in it?
28) What is the size of each segment?
29) Basic difference between 8085 and 8086?
30) Which operations are not available in 8085?
31) What is the difference between min mode and max mode of 8086?
32) What is the difference between near and far procedure?

Alva‟s Institute of Engineering & Technology, Moodbidri 60


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

33) What is the difference between Macro and procedure?


34) What is the difference between instructions RET & IRET?
35) What is the difference between instructions MUL & IMUL?
36) What is the difference between instructions DIV & IDIV?
37) What is difference between shifts and rotate instructions?
38) Which are strings related instructions?
39) Which are addressing modes and their examples in 8086?
40) What does u mean by directives?
41) What does u mean by Prefix?
42) What .model small means?
43) Difference between small, medium, tiny, huge?
44) What is dd, dw, db?
45) Interrupts in 8086 and there function.
46) What is the function of 01h of Int 21h?
47) What is the function of 02h of Int 21h?
48) What is the function of 09h of Int 21h?
49) What is the function of 0Ah of Int 21h?
50) What is the function of 4ch of Int 21h?
51) What is the reset address of 8086?
52) What is the size of flag register in 8086? Explain all.
53) What is the difference between 08H and 01H functions of INT 21H?
54) Which is faster- Reading word size data whose starting address is at even or at odd address
of memory in 8086?
55) Which are the default segment base: offset pairs?
56) Can we use SP as offset address holder with CS?
57) Which are the base registers in 8086?
58) Which is the index registers in 8086?
59) What do you mean by segment override prefix?
60) Whether micro reduces memory requirements?
61) What do you mean by macro?
62) What is diff between macro and procedure?
63) Types of procedure?
64) What TASM is?
65) What TLINK is?
66) What TD is?
67) What do u mean by assembler?
68) What do u mean by linker?
69) What do u mean by loader?
70) What do u mean by compiler?
71) What do u mean by emulator?
72) Stack related instruction?
73) .stack 100 means?
74) What do you mean by 20 dup (0)?
75) Which flags of 8086 are not present in 8085?
76) What is the size of flag register?
77) Can you perform 32 bit operation with 8086? How?
78) Whether 8086 is compatible with Pentium processor?

Alva‟s Institute of Engineering & Technology, Moodbidri 61


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

79) What is 8087? How it is different from 8086?


80) While accepting no. from user why u need to subtract 30 from that?
81) While displaying no. from user why u need to add 30 to that?
82) What are ASCII codes for nos. 0 to F?
83) How does U differentiate between positive and negative numbers?
84) What is range for these numbers?
85) Which no. representation system you have used?
86) What is LEA?
87) What is @data indicates in instruction- MOV ax, @data?
88) What is maximum size of the instruction in 8086?
89) Why we indicate FF as 0FF in program?
90) What is mul BX and div BX? Where result goes?
91) Where queue is present?
92) What is the advantage of using internal registers?
93) What is SI, DI and their functions?
94) Which are the pointers used in 8086 and their functions?
95) What is a type of queue in 8086?
96) What is minimum mode of 8086?
97) What is maximum mode of 8086?
98) Which are string instructions?
99) In string operations which is by default string source pointer?
100) In string operations which is by default string destination pointer?

PROGRAMS:
1) What do you mean by assembler?
2) What do you mean by linker?
3) What do you mean by debugger?
4) What do you mean by compiler?
5) What do you mean by locator?
6) What do you mean by emulator?
7) When divide overflow error occurs?
8) What .startup stands for?
9) Explain the logic of array addition program.
10) Explain the logic of finding out negative nos. from an array of signed nos.
11) Explain the logic of code conversion (BCD to hex and hex to BCD) program.
12) Explain the logic of multiplication (by successive addition and shift and add method)
program.
13) Explain the logic of non overlap and overlap block transfer program.
14) Explain the logic of string related programs.
15) Which assembler directives are used with near procedure?
16) Which assembler directives are used with far procedure?

80386 (microprocessor):
1) What IC 80386 is?
2) How many pin IC 80836 is?
3) 80386 is how many bit processor?
4) What is the size of instruction queue in 80386?

Alva‟s Institute of Engineering & Technology, Moodbidri 62


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

INTERRUPTS:
1) What do you mean by interrupt?
2) Which are the hardware and software interrupts in 8086?
3) Mention the priority of interrupts in8086.
4) What is int1, int2, int3?
5) What do you mean by NMI interrupt?
6) What do you mean by IVT in 8086?
7) What is the size of IVT?
8) Where IVT is located?
9) Which steps 8086 follows to handle any interrupt?

INTERFACING:
1) What are the types of interfacing?
2) Compare memory interfacing and IO interfacing.
3) What are the types of IO interfacing?
4) What is the difference between direct and indirect IO interfacing?
5) What is the difference between memory mapped IO and IO mapped IO interfacing?

8255 (programmable peripheral interface):


1) What IC 8255 is?
2) How many pin IC 8255 is?

By: MAHESH PRASANNA K.


DEPT. OF E & C, AIET.
********************************************************************************************************
QUESTION BANK FOR MICROPROCESSOR LAB
Class : VI Sem E & C Subject Code : 06 ECL – 68
IA Marks : 25 Exam marks : 50

1. a) Write an ALP to move a block of data from source to destination with overlap.
Source address ____, Destination address: ____, Number of bytes to be transferred:_____.
b) Write an ALP to find the LCM of two 16-bit numbers.
2. a) Write an ALP to interchange two blocks of data.
b) Write an ALP to convert 16-bit binary number to BCD number.
3. a) Write an ALP to move block of data without overlap.
b) Write an ALP to interface 7-segment display for rolling display of a given string ____.
4. a) Write an ALP to add two multiprecision numbers. Number1: ____ Number2: ____.
b) Write an ALP to find whether the given number is 2 out of 5 code or not.
5. a) Write an ALP to subtract two multiprecision numbers. Number1: ____ Number2: ____ .
b) Write an ALP to interface a logic controller and verify the truth table for the given expression. y = ______.
6. a) Write an ALP to divide 32- bit by 16- bit number / a 16- bit number by an 8-bit number.
b) Write an ALP to convert BCD number to binary number.
7. a) Write an ALP to illustrate the use of AAA instruction.
b) Write an ALP to transfer a string from source to destination.

Alva‟s Institute of Engineering & Technology, Moodbidri 63


Department of Electronics & Communication Engineering
MICROPROCESSOR LAB MANUAL

8. a) Write an ALP to illustrate the use of AAM instruction.


b) Write an ALP to reverse a given string.
9. a) Write an ALP to illustrate the use of AAS instruction.
b) Write an ALP to search a character in the given string. String: ____ Character: ____.
10. a) Write an ALP to find the square and cube of a 16- bit number.
b) Write an ALP to find whether a given string is a palindrome or not.
11. a) Write an ALP to find the HCF of two 16-bit numbers.
b) Write an ALP to create a new file, write on to it and read from the file.
12. a) Write an ALP to find the factorial of an 16-bit number.
b) Write an ALP to count the number of positive & negative numbers in a given array.
13. a) Write an ALP to count the number of odd and even numbers in a given array of N numbers .
b) Write an ALP to interface a keyboard and store the value of key pressed in a memory location.
14. a) Write an ALP to count the number of ones and zeros in the given data (8/16bit).
b) Write an ALP to read the system date, day and month and display on console.
15. a) Write an ALP to verify whether the given 8/16 bit data is bit wise palindrome or not.
b) Write an ALP to display a string of characters on console.
16. a) Write an ALP to verify whether the given 8/16 bit data is a nibble wise palindrome or not.
b) Write an ALP to add N 16 bit numbers stored in consecutive memory locations.
17. a) Write an ALP to find the largest / smallest number in the given array.
b) Write an ALP to interface a logic controller and verify the truth table for the given expression. y= _____.
18. a) Write an ALP to arrange the given numbers in ascending / descending order.
b) Write an ALP to multiply two 16-bit numbers / 32 bit numbers
19. a) Write an ALP to display a string of characters on console.
b) Write an ALP to interface a keyboard and store the value of key pressed in a memory location.
20. a) Write an ALP to obtain buffered keyboard input using DOS interrupts.
b) Write an ALP to Interface 7-segment display for rolling display of a given string. String: __________.
21. a) Write an ALP to create a new file using DOS interrupts.
b) Write an ALP to Interface 7-segment display for constant display of a given string. String: __________.
22. a) Write an ALP to Interface 7-segment display for constant display of a given string. String: __________.
b) Write an ALP to add N 16 bit numbers stored in consecutive memory locations.
23. a) Write an ALP to read a character from keyboard.
b) Write a program to control the stepper motor to rotate in clockwise / anticlockwise direction.
24. a) Write an ALP to multiply two 32 bit numbers
b) Write an ALP to move block of data without overlap.

NOTE: The examiner may change the combinations.


By: MAHESH PRASANNA K.
DEPT. OF E & C, AIET.

_______________*********_______________
*********

Alva‟s Institute of Engineering & Technology, Moodbidri 64

You might also like