You are on page 1of 15

Microprocessor and Assembly Language

Chapter 3

Registers for 8086

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Comparison of 8086 with 8085

8085 Microprocessor 8086 Microprocessor


It is 8-bit Microprocessor It is 16-bit Microprocessor
It has 16-bit address line. It has 20-bit address line.
It has 8-bit data bus. It has 16-bit data bus.
The clock speed of 8085 microprocessor is 3 MHz The clock speed of 8086 can vary between 5, 8 and
10 MHz for three different microprocessor.
It has 5 flags. It has 9 flags.
It does not support pipe-lining. It supports pipe-lining.
Its operate on clock cycle with 50% duty cycle. Its operate on clock cycle with 33% duty cycle.

It does not support memory segmentation It support memory segmentation


The 8085 microprocessor has 6500 transistor. The 8086 microprocessor has 29000 transistors.
The 8085 microprocessor is Accumulator based The 8086 microprocessor is general purpose
processor. register based processor.
The 8085 has no minimum or maximum mode. The 8086 has minimum and maximum mode.
In 8085 microprocessor only one processor In 8086 more than one processor is being
is being used. used (additional external processor can be
used).
In 8085 microprocessor only 64 KB In 8086 microprocessor 1 MB is used.
memory is used together.

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Comparison of 8086 with 8088

8086 Microprocessor 8088 Microprocessor


8086 has 16-bit data lines. 8088 has 8-bit data lines.
8086 is available in three clock speed 5 Whereas 8088 is available in two clock
MHz, 8 MHz and 10 MHz speed 5 MHz and 8 MHz
The memory space of 8086 is organized The memory space of 8088 is
as two 512KB banks. implemented as single 1M*8 Memory
bank.
8086 has 6-byte instruction queue. 8088 has 4-byte instruction queue.
The 8086 has BHE (Bank high enable) The 8088 has SSO status signal.
The 8086 can read or write 8-bit or 16-bit The 8088 can read/write 8-bit data at a
data at a time. time.
The I/O voltages level for 8086 is The I/O voltages level for 8088 is
measured at 2.5 mA. measured at 2 mA.
The 8086 draws maximum supply current The 8086 draws maximum supply current
of 360mA. of 340mA.

Interrupts in 8086

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Type 2 (INT 02):


 Whenever NMI pin is activated, CPU jumps to 00008H to fetch CS : IP of ISR
associated with NMI.

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Type 4 (INT 04):


 It is invoked when signed number overflows.
 It interrupts on overflow.

MACHINE LANTER GUAGE :


Elemental language of computers, consisting of a string of 0s and 1s. Because machine
language is the lowest-level computer language and the only language that computers
directly understand, a program written in a more sophisticated language (e.g., C, Pascal)
must be converted to machine language prior to execution. This is done via a compiler or
assembler. The resulting binary file (also called an executable file) can then be executed
by the CPU.

Every computer has its own machine language, which is the only language understood by
the computer. Originally, programs were written in machine language. But now programs
are written in special programming languages, but these programs must be translated in to
the machine language of the computer before the program can be executed. Machine
language instructions are represented by binary numbers i.e., sequence consisting of
zero's and one's.
For e.g:001010001110
could represent a 12-bit machine language instruction. This instruction is divided into
two parts an operation code(or op code) and an operand, e.g:
Op code 001, Operand 010001110

The op code specifies the operation(add,multiply,move.....) and the operand is the address
of the data item that is to be operated on. Besides remembering the dozens of code
numbers for the operations, the programmer also has to keep track of the addresses of all
the data items. Thus programming in machine language is highly complicated and subject
to error. Also, the program is program is machine independent.

Machine code is extremely difficult for humans to read because it consists merely of
patterns of bits (i.e., zeros and ones). Thus, programmers who want to work at the
machine code level instead usually use assembly language, which is a human-readable
notation for the machine language in which the instructions represented by patterns of

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

zeros and ones are replaced with alphanumeric symbols (called mnemonics) in order to
make it easier to remember and work with them (including reducing the chances of
making errors). In contrast to high-level languages (e.g., C, C++, Java, Perl and Python),
there is a nearly one to one correspondence between a simple assembly language and its
corresponding machine language.

ASSEMBLY LANGUAGE:

Assembly language is essentially the native language of your computer. Technically the
processor of your machine understands machine code (consisting of ones and zeroes).
But in order to write such a machine code program, you first write it in assembly
language and then use an assembler to convert it to machine code.

However nothing is lost when the assembler does its conversion, since assembly
language simply consists of mnemonic codes which are easy to remember (they are
similar to words in the english language), which stand for each of the different machine
code instructions that the machine is capable of executing.

Because it is extremely low level, assembly language can be optimized extremely well.
Therefore assembly language is used where the utmost performance is required for
applications.

Assembly language is also useful for communicating with the machine at a hardware
level. For this reason, it is often used for writing device drivers.

A third benefit of assembly language is the size of the resulting programs. Because no
conversion from a higher level by a compiler is required, the resulting programs can be
exceedingly small. For this reason, assembly language has been a language of choice for
the demo scene.

Assembler

Typically a modern assembler creates object code by translating assembly instruction


mnemonics into opcodes, and by resolving symbolic names for memory locations and
other entities.[1] The use of symbolic references is a key feature of assemblers, saving
tedious calculations and manual address updates after program modifications. Most
assemblers also include macro facilities for performing textual substitution—e.g., to
generate common short sequences of instructions as inline, instead of called subroutines.

Assembler: Has to know


How to interpret machine language (directives, instructions, addressing modes etc)
Where to place the instructions in memory
Where to place the data in memory ; Scans through source program, keeps track of all
names and corresponding numerical values in symbol table e.g. what all the labels mean

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Calculate branch addresses; Forward branch problem– how can it work out forward
addresses?

Assemblers are generally simpler to write than compilers for high-level languages, and
have been available since the 1950s. Modern assemblers, especially for RISC
architectures, such as SPARC or POWER, as well as x86 and x86-64, optimize
Instruction scheduling to exploit the CPU pipeline efficiently.

Number of passes

There are two types of assemblers based on how many passes through the source are
needed to produce the executable program.

 One-pass assemblers go through the source code once and assume that all
symbols will be defined before any instruction that references them.
 Two pass assembler: The whole process is divided into two passes
 First pass
– create a table with all symbols and their values in the first pass
 Second pass
– use the table in a second pass to generate codemachine code, substituting values
for the labels. The assembler must at least be able to determine the length of each
instruction on the first pass so that the addresses of symbols can be calculated.

The advantage of a one-pass assembler is speed, which is not as important as it once was
with advances in computer speed and abilities. The advantage of the two-pass assembler
is that symbols can be defined anywhere in program source code. This lets programs be
defined in more logical and meaningful ways, making two-pass assembler programs
easier to read and maintain.[2]

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

. Scaling Factors

 You can use scaling to index into arrays with different sizes of elements.
 For example, the scaling factor is

1 for byte arrays (no scaling needed), 2 for word arrays, 4 for doubleword arrays, and 8
for quadword arrays.

Basic elements

There is a large degree of diversity in the way the authors of assemblers categorize
statements and in the nomenclature that they use. In particular, some describe anything
other than a machine mnemonic or extended mnemonic as a pseudo-operation (pseudo-
op). A typical assembly language consists of 3 types of instruction statements that are
used to define program operations:

 Opcode mnemonics
 Data sections
 Assembly directives

Opcode mnemonics and extended mnemonics


Instructions (statements) in assembly language are generally very simple, unlike those in
high-level language. Generally, a mnemonic is a symbolic name for a single executable
machine language instruction (an opcode), and there is at least one opcode mnemonic
defined for each machine language instruction. Each instruction typically consists of an
operation or opcode plus zero or more operands. Most instructions refer to a single value,
or a pair of values. Operands can be immediate (typically one byte values, coded in the
instruction itself), registers specified in the instruction, implied or the addresses of data
located elsewhere in storage. This is determined by the underlying processor architecture:
Data section and assembly directives will be discussed in next section.

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

We have following segments in our program

1.Assembly directives
Assembly directives, also called pseudo opcodes, pseudo-operations or pseudo-ops, are
instructions that are executed by an assembler at assembly time, not by a CPU at run
time. They can make the assembly of the program dependent on parameters input by a
programmer, so that one program can be assembled different ways, perhaps for different
applications. They also can be used to manipulate presentation of a program to make it
easier to read and maintain.

2.Data sections
There are instructions used to define data elements to hold data and variables. They
define the type of data, the length and the alignment of data. These instructions can also
define whether the data is available to outside programs (programs assembled separately)
or only to the program in which the data section is defined. Some assemblers classify
these as pseudo-ops.

3.Macros

Many assemblers support predefined macros, and others support programmer-defined


(and repeatedly re-definable) macros involving sequences of text lines in which variables
and constants are embedded. This sequence of text lines may include opcodes or
directives. Once a macro has been defined its name may be used in place of a mnemonic.
When the assembler processes such a statement, it replaces the statement with the text
lines associated with that macro, then processes them as if they existed in the source code
file (including, in some assemblers, expansion of any macros existing in the replacement
text).

Since macros can have 'short' names but expand to several or indeed many lines of code,
they can be used to make assembly language programs appear to be far shorter, requiring
fewer lines of source code, as with higher level languages. They can also be used to add
higher levels of structure to assembly programs, optionally introduce embedded
debugging code via parameters and other similar features.

4.Code section
In the code section we will write actual program containing instructions to perform the
required task.
Assembling, Linking and Executing
1) Assembling:
- Assembling converts source program into object program if syntactically correct and
generates an intermediate .obj file or module.
- It calculates the offset address for every data item in data segment and every

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

instruction in code segment.


- A header is created which contains the incomplete address in front of the generated obj
module during the assembling.
- Assembler complains about the syntax error if any and does not generate the object
module.
- Assembler creates .obj .lst and .crf files and last two are optional files that can be
created at run time.
- For short programs, assembling can be done manually where the programmer translates
each mnemonic into the machine language using lookup table.
- Assembler reads each assembly instruction of a program as ASCII character and
translates them into respective machine code.
2) Linking:
- This involves the converting of .OBJ module into .EXE(executable) module i.e.
executable machine code.
- It completes the address left by the assembler.
It combines separately assembled object files.
- Linking creates .EXE, .LIB, .MAP files among which last two are optional files.
3) Loading and Executing:
- It Loads the program in memory for execution.
- It resolves remaining address.
- This process creates the program segment prefix (PSP) before loading.
- It executes to generate the result.

Instructor : Nitin P.
Microprocessor and Assembly Language
Chapter 3

Macros in assembly language

1.

Look at avove example we defined a macro with name addition and there is two
parameter VAL1 and VAL2 for the given macro.

Instructor : Nitin P.

You might also like