Micro
Micro
DATA SEGMENT
ARRAY DB 15H,05H,08H,78H,56H
DATA ENDS
CODE SEGMENT
START:ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
MOV BL,05H
MOV CL,04H
CMP AL,[SI+1]
JNC DOWN
XCHG AL,[SI+1]
XCHG AL,[SI]
DOWN:ADD SI,1
LOOP STEP
DEC BL
JNZ STEP1
MOV AH,4CH
INT 21H
CODE ENDS
END START
Demonstrate in detail the program development steps in assembly language programming.
Program Development steps 1. Defining the problem The first step in writing program is to think very
carefully about the problem that you want the program to solve.
2. Algorithm The formula or sequence of operations or task need to perform by your program can
be specified as a step in general English is called algorithm.
4. Initialization checklist Initialization task is to make the checklist of entire variables, constants, all
the registers, flags and programmable ports.
5. Choosing instructions We should choose those instructions that make program smaller in size and
more importantly efficient in execution.
6. Converting algorithms to assembly language program Every step in the algorithm is converted
into program statement using correct and efficient instructions or group of instructions.
Draw architectural block diagram of 8086 and describe its register organization
4. DX – holds the high 16 bits of the product in multiply (also handles divide operations)
5. CS – Code Segment – holds base address for all executable instructions in a program
8. ES – Extra Segment – additional base address for memory variables in extra segment.
10. SP – Stack Pointer – Contains the offset of the top of the stack.
11. SI – Source Index – Used in string movement instructions. The source string is pointed to by the
SI register.
12. DI – Destination Index – acts as the destination for string movement instructions
13. IP – Instruction Pointer – contains the offset of the next instruction to be executed.
14. Flag Register – individual bit positions within register show status of CPU or results of arithmetic
operations.
Write ALP using macro to perform multiplication of two 8 Bit Unsigned number
MOV AL,FIRST
MOV BL,SECOND
MUL BL
PRODUCT ENDM
DATA SEGMENT
NO1 DB 05H
NO2 DB 04H
MULTIPLE DW ?
DATA ENDS
START:MOV AX,DATA
MOV DS,AX
PRODUCT NO1,NO2
MOV MULTIPLE, AX
MOV AH,4CH
INT 21H
CODE ENDS
END
ADD AL,BL
RET
SUM ENDP
DATA SEGMENT
NUM1 DB 10H
NUM2 DB 20H
NUM3 DB 30H
NUM4 DB 40H
RESULT DB?
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AL,NUM1
MOV BL,NUM2
CALL SUM
MOV CL,AL
MOV BL,NUM4
CALL SUM
MUL CL
MOV RESULT,AX
MOV AH,4CH
INT 21H
CODE ENDS
END
Write ALP to perform block transfer operation of 10 numbers.
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV CX,000AH
LEA SI,BLOCK1
LEA DI,ES:BLOCK2
MOV
AX,4C00H
INT 21H
CODE ENDS
DATA SEGMENT
1865H, 2345H,4000H,8888H
DATA ENDS
EXTRA SEGMENT
BLOCK2 DW ?
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV CX,000AH
LEA SI,BLOCK1
LEA DI,ES:BLOCK2
MOV AX,4C00H
INT 21H
CODE ENDS
DATA SEGMENT
1865H, 2345H,4000H,8888H
DATA ENDS
EXTRA SEGMENT
BLOCK2 DW ?
EXTRA ENDS
END
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MOV DX,0000H
MOV CX,COUNT
ROR AX,01H
JC ODD_1
INC DL
JMP COUNT_IT
ODD_1 : INC DH
LOOP NEXT
MOV ODD_COUNT,DH
MOV EVENCNT,DL
MOV AH,4CH
INT 21H
CODE ENDS
DATA SEGMENT
COUNT DW 0AH
ODD_COUNT DB ?
EVENCNT DB ?
DATA ENDS
END START
Describe mechanism for generation of physical address in 8086 with suitable example.
As all registers in 8086 are of 16 bit and the physical address will be in 20 bits. For this reason the
above mechanism is helpful.
Program:
DATA SEGMENT
DATA ENDS
CODE SEGMENT
START:ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
LEA SI,STRB
MOV CL,0FH
LEA DI,REV
ADD DI,0FH
UP:MOV AL,[SI]
MOV [DI],AL
INC SI
DEC DI
LOOP UP
MOV AH,4CH
INT 21H
CODE ENDS
END START
Define logical and effective address. Describe physical address generation process in 8086. If
DS=345AH and SI=13DCH. Calculate physical address.
A logical address is the address at which an item (memory cell, storage element) appears to reside
from the perspective of an executing application program. A logical address may be different from
the physical address due to the operation of an address translator or mapping function. Effective
Address or Offset Address: The offset for a memory operand is called the operand's effective
address or EA. It is an unassigned 16 bit number that expresses the operand's distance in bytes from
the beginning of the segment in which it resides. In 8086 we have base registers and index registers.
1. Segment registers carry 16 bit data, which is also known as base address.
2. BIU appends four 0 bits to LSB of the base address. This address becomes 20-bit address.
4. Offset address is added into 20-bit base address which finally forms 20 bit physical address of
memory location
= 345A0+13DC
= 3597CH
Write an ALP to find largest number in array of elements 10H, 24H, 02H, 05H, 17H.
DATA SEGMENT
ARRAY DB 10H,24H,02H,05H,17H
LARGEST DB 00H
DATA ENDS
CODE SEGMENT
START:
MOV DS,DX
MOV CX,04H
MOV SI ,OFFSET
UP: INC SI
CMP AL,[SI]
JNC NEXT
MOV AL,[SI]
NEXT: DEC CX
JNZ UP
MOV LARGEST,
AL MOV AX,4C00H
INT 21H
CODE ENDS
END START
Write an ALP to count no.of 0’s in 16 bit number.
DATA SEGMENT
N DB 1237H
Z DB 0
DATA ENDS
CODE SEGMENT
START:
MOV DX,DATA
MOV DS,DX
MOV AX, N
MOV CL,08
JC ONE
INC Z
HLT
CODE ENDS
END START
What is pipelining? How it improves the processing speed.
• In 8086, pipelining is the technique of overlapping instruction fetch and execution mechanism.
• To speed up program execution, the BIU fetches as many as six instruction bytes ahead of time
from memory. The size of instruction prefetching queue in 8086 is 6 bytes.
• While executing one instruction other instruction can be fetched. Thus it avoids the waiting time
for execution unit to receive other instruction.
• BIU stores the fetched instructions in a 6 level deep FIFO . The BIU can be fetching instructions
bytes while the EU is decoding an instruction or executing an instruction which does not require use
of the buses.
• When the EU is ready for its next instruction, it simply reads the instruction from the queue in the
BIU
. • This is much faster than sending out an address to the system memory and waiting for memory to
send back the next instruction byte or bytes
.MODEL SMALL
MOV al,a
MUL al
MOV bl,al
MOV al,b
MUL al
ADD al,bl
ENDM
.DATA
x DB 02H
y DB 03H
p DB DUP()
.CODE
START:
MOV ax,data
MOV ds,ax
PROG x, y
MOV p,al
MOV ah,4Ch
Int 21H
END
Explain assembly language program development steps.
1. Defining the problem: The first step in writing program is to think very carefully about the
problem that the program must solve.
4. Initialization checklist: Initialization task is to make the checklist of entire variables, constants, all
the registers, flags and programmable ports
5. Choosing instructions: Choose those instructions that make program smaller in size and more
importantly efficient in execution. 6. Converting algorithms to assembly language program: Every
step in the algorithm is converted into program statement using correct and efficient instructions or
group of instructions.