Lab 1
Lab 1
LAB No 01
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:
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
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:
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).
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).
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.
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.
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
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.