Aiet MP
Aiet MP
Aiet MP
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
*************************************************************************************
INDEX
Page No.
Part – A: Software Programs
DOS Interrupts 34
14. Strings 38
Part – B: Interfacing Programs
Delay Calculations 42
*************************************************************************************
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
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
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
TASM COMMANDS
C : \ cd tasm
C : \ tasm > edit filename.asm
.model type
.data
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.
.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
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
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
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
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.
mov si,00
mov cx,blk_len
mov res+2,dx
int 3 ; Terminates the program execution
align 16
end start
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
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
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
.code
start: mov ax,@data
mov ds,ax ; Initializes DS
push ax
mov dl,20h ; Displays space on the screen before the result
write
pop ax
sub al, bl
jnc next
mov dl, bl
jmp last
last : write
mov ah,4ch ; Terminates the program
int 21h
end start
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 ah,4ch
int 21h ; Terminates the program
end start
int 3
align 16
end start
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
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
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
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
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
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
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]
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. 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.
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
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
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
back: inc si
inc si
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
noxchg: inc si
inc si
dec ch
jnz nxtcmp
dec cl
jnz nxtpas
int 3
align 16
end start
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.
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
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
mov si,00
mov cx,len1
mov bx,len-1
nxt1: inc si
dec bx
loop rpt
TASM COMMANDS:
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
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 fl_hdl,ax
mov dx,offset writeme ; to write msg
mov bx,fl_hdl
mov cx,len
mov ah,40h
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
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
mov dl,bl
mov ah,02
int 21h
mov dl,bh
mov ah,02
int 21h
add dx,ax
mov ah,09
int 21h
add dx,ax
mov ah,09
int 21h
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.
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
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.
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.
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
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
MOV Show[1h], AL
MOV AH, 9h ; Display the character pressed.
MOV DX, OFFSET Show
INT 21h
MOV CX, 0FFFFh
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
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.
; ****************************************************************************************** ;
; 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
; ****************************************************************************************** ;
; 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
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.
; ********************************************************************************************** ;
; 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
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
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.
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?
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?
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?
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.
_______________*********_______________
*********