0% found this document useful (0 votes)
5 views

Lab 1

Uploaded by

maryamkainat2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lab 1

Uploaded by

maryamkainat2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Microprocessor and Interfacing 01/12/2025

LAB No 01

Introduction to 8086 Architecture and Register Set, Use of Emulator and


executing Assembly Language programs

1. Processing Device: A processing device is a hardware component that processes data


according to a set of instructions (program). The most common examples include:
 Microprocessors (e.g., Intel Core i9, AMD Ryzen)
 Microcontrollers (e.g., Arduino, STM32, ATmega328)
 Digital Signal Processors (DSPs)
These devices are designed to perform a wide range of tasks, such as arithmetic operations,
logical decisions, and data transfer, based on input from peripherals or memory.

2. Key Components of a Processing Device: A typical processing device includes:


Control Unit (CU): Directs the flow of data between the processor, memory, and peripherals.
Decodes instructions and coordinates execution.
Arithmetic and Logic Unit (ALU): Handles mathematical computations (addition, subtraction,
etc.) and logical operations (AND, OR, NOT, etc.).
Registers: Small, high-speed storage locations for temporary data during instruction execution.
Clock: Synchronizes operations by providing timing signals.

3. Functionality of a Processing Device


Instruction Fetching: Reads machine instructions from memory.
Decoding: Interprets the fetched instruction to determine the operation and required data.
Execution: Executes the operation, involving ALU or data transfer.
Result Storage: Stores the output in registers or memory for further use.

What is a Microprocessor?
A device that takes data as its input, processes the data and outputs the result. The important
characteristics of a microprocessor are the widths of its internal and external address bus and
data bus (and instruction), its clock rate and its instruction set.

What is a Register?
Small numbers of high-speed memory locations in a microprocessor.
Microprocessor and Interfacing 01/12/2025

Microprocessor’s Differences:
Different microprocessors have different specifications; the main differences they hold are:

Instruction Set: operations, addressing modes.


Registers: size, number
Address bus: size (number of bits).
Data bus: size

4. Instruction in 8086: In 8086 microprocessors, an instruction is a binary-encoded command


that directs the processor to perform a specific task, such as moving data, performing arithmetic,
logical operations, or controlling program flow. 8086 supports a rich set of instructions as part of
its instruction set architecture (ISA).

5. Structure of an 8086 Instruction: An 8086 instruction consists of,


o Opcode (Operation Code): Specifies the operation to perform (e.g., MOV,
ADD, SUB).
o Operands: Specify the source and destination for the operation. Operands can be:
 Registers (e.g., AX, BX, CX, DX).
 Memory locations (using an address or offset).
 Immediate values (e.g., #10).
o Addressing Mode: Determines how the operands are accessed, such as direct
addressing, indirect addressing, or immediate addressing.

6. Classification of 8086 Instructions: 8086 instructions are grouped based on the following
functionalities.
o Data Transfer Instructions: Used to transfer data between registers, memory,
and I/O ports. For example:
 MOV AX, BX (Move the content of BX into AX).
 PUSH AX (Push the content of AX onto the stack).
 POP BX (Pop the top of the stack into BX).
o Arithmetic Instructions: Perform mathematical operations. For example:
 ADD AX, BX (Add BX to AX).
 SUB AX, 05h (Subtract 05h from AX).
 MUL CX (Multiply AX by CX).
o Logical Instructions: Perform bitwise operations. For example:
 AND AX, BX (Perform bitwise AND between AX and BX).
 OR AX, 0Fh (Perform bitwise OR with 0Fh).
o Control Transfer Instructions: Alter the sequence of execution. For example:
 JMP 2000h (Jump to memory location 2000h).
Microprocessor and Interfacing 01/12/2025

 CALL 1234h (Call the subroutine at address 1234h).


 RET (Return from a subroutine).
o Input/Output Instructions: Facilitate communication with peripheral devices.
For example:
 IN AL, DX (Input data from a port specified by DX into AL).
 OUT DX, AL (Output data from AL to a port specified by DX).
o String Manipulation Instructions: Operate on strings of data. For example:
 MOVSB (Move a byte from the source string to the destination string).
 CMPSB (Compare bytes of two strings).
o Machine Control Instructions: Manage the processor’s operations. For
example:
 HLT (Halt the processor).
 NOP (No operation).

7. Instruction Cycle in 8086: The 8086-instruction cycle includes four steps:


 Fetch: Retrieve the instruction from memory.
 Decode: Decode the opcode and identify the operands.
 Execute: Execute the operation specified by the instruction.
 Write Back: Store the result in the specified location.

8. Examples of 8086 Instructions: Here are some specific examples for the 8086
microprocessors:
 MOV AX, 1234h; Move the immediate value 1234h into the AX register.
 ADD AX, BX; Add the content of BX to AX.

Storage of Data Structures of a Microprocessor: There are two ways to store data structures.
For multiple-byte data items stored in memory, the order needs to be specified:

Most Significant 8 bits at lowest address ("Big Endian"),


OR
Least Significant 8 bits at lowest address ("Little Endian")

1100 1101

Registers:
Microprocessor and Interfacing 01/12/2025

The four data registers labeled AX, BX, CX and DX may be further subdivided for 8-bit
operations into a high-byte or low-byte register. Thus, for byte operations, the registers may be
individually addressed. So, each of these are 16 bits wide, but can be accessed as a byte or a
word.
AX: known as an accumulator is used in arithmetic and logical operations.
BX: refers to the 16-bit base register.
CX: is used as a counter.
DX: Data Register.
Basic Instructions and its Use:
Mov and Add explained

9. BUS: As we already know that bus is a collection of parallel wires or lines that connect
different components in a computer system. The primary role of a bus is to facilitate
communication by transmitting:
 Data (information to be processed or stored),
 Addresses (locations in memory or I/O devices),
 Control Signals (commands to manage operations like read/write).

The 8086 microprocessor has three main types of buses:


A. Address Bus
o Carries the memory or I/O address of the data that the processor wants to
access.
o Unidirectional: Information flows only from the processor to the memory or
peripherals.
o Size: 20 bits in 8086 (allows addressing up to 220=1MB2^{20} = 1 MB220=1MB
of memory).
B. Data Bus
o Transfers actual data between the processor, memory, and peripherals.
o Bidirectional: Data can flow both to and from the processor.
o Size: 16 bits in 8086 (can handle 2 bytes of data at a time).
C. Control Bus
o Sends control signals to coordinate operations like reading or writing data.
o Examples of control signals:
 RD̅: Read signal (to read data from memory or an I/O device).
 WR̅: Write signal (to write data to memory or an I/O device).
 READY: Indicates whether a device is ready for data transfer.
 HLDA: Hold Acknowledge, for DMA operations.
Microprocessor and Interfacing 01/12/2025

Bus Organization in 8086: The 8086 microprocessor features multiplexed buses to optimize pin
count:
 The address and data lines are multiplexed (shared).
 Lower 16 bits of the address bus (A0–A15) are shared with the data bus (D0–D15).
 During the address phase, these lines carry the address.
 During the data phase, they carry data.
This multiplexing is managed using latches (e.g., 74LS373) and control signals (like ALE - Address
Latch Enable).

Bus Cycles in 8086: The 8086 bus cycle describes how the processor interacts with memory or
peripherals via buses. Each bus cycle has distinct steps:
1. T1 (Address Phase):
o The processor places the address on the address bus.
o ALE signal is activated to latch the address.
2. T2 (Command Phase):
o The processor sets the control signals (e.g., RD̅, WR̅) to indicate the operation.
3. T3/T4 (Data Phase):
o The data is transferred on the data bus (read/write).
4. Idle/Wait State:
o Additional states may occur if the device is slow to respond (using the READY
signal).

11. block diagram of 8086 microprocessor-based system:

1. Microprocessor (CPU): The microprocessor is the brain of the system. It performs


arithmetic, logical, and control operations. It consists of:
o Arithmetic and Logic Unit (ALU): Executes arithmetic and logical operations.
Microprocessor and Interfacing 01/12/2025

o Control Unit: Directs the operations of the system by controlling data flow.
o Registers: Temporary storage for data and instructions.
2. Memory
o RAM (Random Access Memory): Volatile memory for storing data and
instructions temporarily while the system is running.
o ROM (Read-Only Memory): Non-volatile memory that stores system
instructions, like the boot program.
3. Input Unit: Accepts data from external devices (e.g., keyboard, sensors) and converts it
into a format understandable by the microprocessor.
4. Output Unit: Converts processed data into human-readable form (e.g., on a monitor or
through an actuator) or interfaces with external devices.
5. System Bus: A communication pathway that connects the CPU, memory, and I/O
devices. It has three main components:
o Address Bus: Carries memory addresses for read/write operations.
o Data Bus: Transfers actual data between CPU, memory, and peripherals.
o Control Bus: Sends control signals (e.g., read/write commands).
6. I/O Devices: Peripheral devices such as keyboards, mice, displays, printers, or
communication modules. These are interfaced via the Input/Output unit.
7. Clock: A timing device that provides synchronization signals for the microprocessor’s
operations, ensuring tasks are carried out in proper sequence.
8. Power Supply: Supplies the required electrical power for the microprocessor and other
components in the system.
9. Peripheral Interfaces: Additional circuits like timers, serial/parallel communication
modules, or A/D (Analog to Digital) and D/A (Digital to Analog) converters that extend
the system’s functionality.

How to use Emulator:


Once you open the emu8086 emulator you should see the following screen
Microprocessor and Interfacing 01/12/2025

From here on you can create a new project with following options-

This screen allows you select what kind of file you want create- either a bin file with .com
extension, an executive file with .exe extension, a pure binary file or a boot file. Once you select
the type the emu8086 opens the editor with a readymade template of the kind of file you
wanted to create.

Consider that you selected .exe template then the editor opens with default template as shown
below,
Microprocessor and Interfacing 01/12/2025

From here on you can write the code in the add your code here section, change the code, data
segment part and define constant or variables.

If you select cancel in the above default template selection then it opens just the blank editor
as shown below,
Microprocessor and Interfacing 01/12/2025

From here you can write you assembly program. For example, consider the simple program that
loads the accumulator with some values, add new value to the content of the accumulator and
so on.

mov ax, 10
add ax, 21
inc ax
dec ax
sub ax, 12
add ax, 7
inc ax
dec ax
sub ax, 30

Once you have typed in your program, you should save the program by going to File>Save or
File>save as or just by clicking the save button on the toolbar. Emu8086 will save it the newly
created file with .asm extension in its default location(C:\emu8086\MySource) but you can
browse to a folder where you want to save the file.

Once you have saved the file, you can emulate the program by clicking on the emulate button
on the toolbar to see the behavior of the program. That is what register has what content, the
flag resisters that gets effected by the program and so on.

The screenshot below shows this process.


Microprocessor and Interfacing 01/12/2025

From this emulator window we can just run the program or go through the program step by
step by clicking on the single step button. For the example program above, when we step
through the program we can see the content of the accumulator and how it gets modified and
what new values are stored. Not only can we know the content of the accumulator but also the
other registers, the stack, and the flag register.
Microprocessor and Interfacing 01/12/2025

The stack content is shown below,

The Flag Register is shown below,


Microprocessor and Interfacing 01/12/2025
Microprocessor and Interfacing 01/12/2025

Lab Tasks

Practice and execute the following tasks and note down all the changes you observe.
CLO [1]

TASK 1:
Write the following code in the emulator and examine the contents of registers by single
stepping.

org 100h
MOV AL, 57H
MOV DH, 69
MOV DL, 72
MOV BX, DX
MOV BH, AL
MOV BL, 9FH
MOV AH, 20
ADD AX, DX
ADD CX, BX
ADD AX, 1F35H
ret

Task 02:
Write a program to subtract the content of register DX from the content of register AX, then
add the result to the content of CX. Set the registers to 4, 0A and 1F respectively.
SUB AX, DX
ADD AX, CX

Task 03:

Write a program to add the content of register BX to the content of register CX, then subtract
the result from the content of AX. Set the registers to 05, 12, and 2A, respectively.

Task 04:

Write a program to multiply the content of register DX with the content of AX, then add the
result to the content of BX. Set the registers to 03, 07, and 0F, respectively.
Microprocessor and Interfacing 01/12/2025

Task 05:

Write a program to divide the content of register AX by the content of BX, then add the result
to the content of DX. Set the registers to 18, 03, and 05, respectively.

Task 06:
Add three binary numbers to get the result of 30 in assembly?

Task 07:
MOV AL, ‘9’
ADD AL, ‘5’
Have a close look at the results?

Task 08:
MOV AL, 'G'
SUB AL, 'C'
Observe the result in AL and determine its significance.

Task 09:
MOV AL, 250
ADD AL, 20
; Check the result in AL and note if an overflow occurs.

Task 10:
MOV AL, 'A'
ADD AL, '3'
; Observe the result in AL and think about why it happens.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy