Professional Documents
Culture Documents
The main purpose of this experiment was studied about 8086 instructions and programming
with 8086 Single and Multidimensional Arrays. A Single or Multidimensional Arrays code is
implemented with EMU8086 to study advanced how 8086 operate. After that, it complied with
MASM software. MASM converts source code to object code. The object code was introduced
to the microprocessor 8086 using MTS-86C.
Introduction:
In 8086 there are many instructions. In this laboratory some instructions and mainly use of
arrays will be observed. In this experiment the main objective is:
1) To work with advanced 8086 instructions.
2) To learn how to write assembly programs using 8086 instructions and arrays.
Few More 8086 instructions (Please refer 8086 instructions from [1] for more instructions:
inc Increment by 1
Syntax: inc op
op: register or memory
Action: op = op + 1
dec Decrement by 1
Syntax: dec op
op: register or memory
Action: op = op - 1
LOOP B1
The LOOP instruction is a combination of a decrement of CX and a conditional jump. In the 8086,
LOOP decrements CX and if CX is not equal to zero, it jumps to the address indicated by the label B1.
If CX becomes a 0, the next sequential instruction executes.
Sample Program
Summation of a series.
[1+2+3+4+………+N] = BX
0005 start:
0005 03 D9 add bx, cx
0007 E2 FC loop start
The 8086 processors lets the user to access the memory in different ways. The 8086 memory addressing
modes provide flexible access to memory, allowing one to easily access variables, arrays, records,
pointers, and other complex data types.
Most 8086 instructions can operate on the 8086's general purpose register set. By specifying the name
of the register as an operand to the instruction, you may access the contents of that register. Consider
the 8086 mov (move) instruction:
mov destination, source
This instruction copies the data from the source operand to the destination operand. The eight and 16
bit registers are certainly valid operands for this instruction. The only restriction is that both operands
must be the same size. Now let's look at some actual 8086 mov instructions:
The registers are the best place to keep often used variables.
In addition to the general purpose registers, many 8086 instructions (including the mov instruction)
allow you to specify one of the segment registers as an operand. There are two restrictions on the use
of the segment registers with the mov instruction. First of all, one may not specify cs as the destination
operand; second, only one of the operands can be a segment register. Data cannot be moved from one
segment register to another with a single mov instruction. To copy the value of cs to ds, to be used some
sequence like:
mov ax, cs
mov ds, ax
Segment registers should not be programmed as data registers to hold arbitrary values. They should
only contain segment addresses.
8086 Memory Addressing Modes
By default, all direct values provide offsets into the data segment. If it is needed to provide an offset
into a different segment, a segment override prefix must be used before the address. For example, to
access location 1234h in the extra segment (es) an instruction of the following form hs to be used.
mov ax,es:[1234h]
mov ds,ax
Likewise, to access this location in the code segment the instruction mov ax, cs:[1234h]has to be used.
The ds: prefix in the previous examples is not a segment override.
For example if DS contains 1000h and BX contains 2345h, Instruction mov al,[bx] will move the
content of memory location 12345h into al. Similarly instruction mov ax,[bx] will move the content of
memory location 12345h and 12346h into AX.
For example if DS contains 1000h and si contains 2345h and a equ 2, Instruction
mov al,a[si] will move the content of memory location 12347h into al. Similarly instruction mov ax,a[si]
will move the content of memory location 12347h and 12348h into AX
Based addressing mode is similar to indexed addressing mode. The only difference is, here BX and BP
register is used to hold offset value. The based addressing modes use the following syntax:
The based indexed addressing modes are simply combinations of the register indirect addressing modes.
These addressing modes form the offset by adding together a base register (bx or bp) and an index
register (si or di). The allowable forms for these addressing modes are
mov al, [bx][si]
mov al, [bx][di]
mov al, [bp][si]
mov al, [bp][di]
In based indexed addressing mode the 20 bit physical address is calculated as:
Physical address= [Value at the segment register]*10+base register value + index register value +
displacement.
Apparatus:
Procedure:
Sample code
code segment
assume CS:code, DS:code
xor ax,ax ; Clearing AX
mov ax,cs
mov ds,ax
mov ax,0000h ; all three lines used to assign both code and data segment in same
memory location
L1:
add al,[Si]
inc si
loop L1
div bl
hlt
Result:
Discussion:
In this experiment there was a little chance for any error. There may be a only scope of error is
typing mistake while typing the codes in in the MTS-86C.The whole experiment was based
on implementation and understanding the code written in the 8086 microprocessor.
Reference(s):