100% found this document useful (1 vote)
480 views

Assembly Language Lab-1

The document introduces assembly language and the 8086 microprocessor. It describes the basic components of a CPU, including registers, buses, and memory. It explains the different types of registers in the 8086, including general purpose, segment, pointer, and status registers. It also covers addressing memory with segment and offset registers, and the roles of the program counter, stack pointer, base pointer, and index registers. Exercises at the end ask about the register set of 32-bit and 64-bit Intel machines.

Uploaded by

mudassar87
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
480 views

Assembly Language Lab-1

The document introduces assembly language and the 8086 microprocessor. It describes the basic components of a CPU, including registers, buses, and memory. It explains the different types of registers in the 8086, including general purpose, segment, pointer, and status registers. It also covers addressing memory with segment and offset registers, and the roles of the program counter, stack pointer, base pointer, and index registers. Exercises at the end ask about the register set of 32-bit and 64-bit Intel machines.

Uploaded by

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

EXPERIMENT 1 – INTRODUCTION TO MICROPROCESSOR LAB AND

ASSEMBLY LANGUAGE

OBJECTIVE
Introduction to microprocessor lab, system and kits and software. Student will get use to the software and lab
equipment, trainers and get use to the lab environment.
TIME REQUIRED : 3 hrs
PROGRAMMING LANGUAGE : NIL
SOFTWARE REQUIRED : Emulator 8086, DOS, Debug
HARDWARE REQUIRED : Core i5 in Computer Labs, MDA – Win8086
INTRODUCTION TO ASSEMBLY LANGUAGE
Assembly language is a low-level programming language. You
need to get some knowledge about computer structure in order
to understand anything. The system bus (shown in yellow)
connects the various components of a computer. The CPU is
the heart of the computer, most of computations occurs inside
the CPU. RAM is a place to where the programs are loaded in
order to be executed.
8086 MICRO-PROCESSOR
We will be studying the assembly language for the microprocessor 8086.
• 8086 micro-processor is a 16-bit microprocessor (a 16-bit microprocessor can operate on the 16-bits of
data at a time) having 16- bit registers.
• 16-bit data bus and 20-bit address bus.
• It can access 1 MB of total memory.
INSIDE A CPU
To write the assembly language programs for 8086 micro-processor, we are required to know the internal
organization at least programming model
GENERAL PURPOSE REGISTERS
8086 CPU has 8 general purpose registers, each register has its own name:
• AX - the accumulator register (divided into AH / AL).
• BX - the base address register (divided into BH / BL).
• CX - the count register (divided into CH / CL).
• DX - the data register (divided into DH / DL).
• SI - source index register.

5 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language


• DI - destination index register.
• BP - base pointer.
• SP - stack pointer.
Despite the name of a register, it's the programmer who determines the usage for each general-purpose register.
The main purpose of a register is to keep a number (variable). The size of the above registers is 16 bit, it's
something like: 0011000000111001b (in binary form), or 12345 in decimal (human) form.
4 general purpose registers (AX, BX, CX, DX) are made of two sep arate 8 bit registers, for example if AX=
0011000000111001b, then AH=00110000b and AL=00111001b. Therefore, when you modify any of the 8-
bit registers 16-bit register is also updated, and vice-versa. The same is for other 3 registers, "H" is for high
and "L" is for low part.
Because registers are located inside the CPU, they are much faster than memory. Accessing a memory location
requires the
use of a
system bus,
so it takes
much longer.
Accessing
data in a
register
usually takes
no time.
Therefore,
you should
try to keep variables in the registers. Register sets are very small, and most registers have special purposes
which limit their use as variables, but they are still an excellent place to store temporary data of calculations.
SEGMENT REGISTERS
• CS - points at the segment containing the current program.
• DS - generally points at segment where variables are defined.
• ES - extra segment register, it's up to a coder to define its usage.
• SS - points at the segment containing the stack.
Although it is possible to store any data in the segment registers, this is never a good idea. The segment
registers have a very special purpose - pointing at accessible blocks of memory. Segment registers work
together with general purpose register to access any memory value. For example, if we would like to access

6 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language


memory at the physical address 12345h (hexadecimal), we should set the DS = 1230h and SI = 0045h. This is
good, since this way we can access much more memory than with a single register that is limited to
16-bit values.
CPU makes a calculation of physical address by multiplying the segment register by 10h and adding general
purpose register to it (1230h * 10h + 45h = 12345h):

The address formed with 2 registers is called an effective address. By default, BX, SI and DI registers work
with DS segment register; BP and SP work with SS segment register.
Other general-purpose registers cannot form an effective address! Also, although BX can form an effective
address, BH and BL cannot!
SPECIAL PURPOSE REGISTERS
• IP - the instruction pointer.
• Flags Register - determines the current state of the processor.
IP register always works together with CS segment register and it points to currently executing instruction.
Flags Register is modified automatically by CPU after mathematical operations, this allows to determine the
type of the result, and to determine conditions to transfer control to other parts of the program. Generally, you
cannot access these registers directly.
REGISTERS CLASSIFICATIONS
The registers inside the microprocessor are classified according to the function they perform. In general, they
are classified as: -
• Data registers
• Address registers
• Segment register
• Offset registers
• Status register
REGISTER SIZE
We have three different sizes of registers:
• 8-bit register: AH, AL, BH, BL, CH, CL, DH, DL
• 16-bit registers: AX, BX, CX, DX, SP, BP, SI, DI, SS, DS, CS, ES, FS, GS, IP, FLAGS
• 32-bit registers: EAX, EXB, ECX, EDX, ESI, EDI, ESP, EBP, EIP, and EFLAGS.
SEGMENT AND OFFSET REGISTER
• Address registers store addresses of instructions and data in memory.

7 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language


• These values are used by the microprocessor to access memory locations.
• Every memory location is identified by an address of 20-bit.
• We are having the registers of 16-bits on that over 20-bit address (Physical Address) is store into two
parts in two 16-bit registers called segment number and offset
• A memory segment is a block of 2^16 (64 K) consecutive memory bytes.
• A segment number, called segment address (starting with 0) identifies each segment.
• A segment number is 16-bits so the highest segment number is FFFFh.
• Within segment, giving an offset number called the offset identifies a memory location.
• This is the number of bytes from the beginning of the segment.
• With a 64KB segment, the offset can be given as a 16-bit number.
• The first byte in a segment has offset 0.
• The last offset in a segment is FFFFh.
PROGRAM SEGMENT
• A machine language program consists of instructions (code) and data.
• A data structure called Stack is used by the microprocessor to implement procedure calls.
• The program’s code, data and stack are loaded into different memory segments, called code segment,
data segment and the stack segment.
SEGMENT REGISTERS
• To keep track of the various program segments, the 8086 microprocessor is equipped with four
segment registers to hold the segment numbers.
• The CS, DS and SS registers contain the code, data and stack segment numbers respectively.
• If a program needs to access a second data segment, it can use the ES (Extra Segment) register.
POINTER AND SEGMENT REGISTER
• The registers SP, BP, SI and DI normally points to (contain the offset address of) memory location.
• These registers can be used in arithmetic and other operations.
SP (STACK POINTER)
• The SP register contains the offset of the top of stack.
• The SP and SS registers combine to form the complete address of the top of the stack.
BP (BASE POINTER)
• The BP register contains an assumed offset from the SS register, as does the stack pointer.
• The BP register is often used by a subroutine to locate variables that were passed on the stack by a
calling program.
• The BP register can be used for other segment unlike SP register.

8 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language


SI (SOURCE INDEX)
• The SI register is used to point to memory locations in the data segment addressed by DS.
• This register takes its name from the string movement instructions, in which the source string is pointed
to by the SI register.
DI (DESTINATION INDEX)
• The DI register performs the same operation as the SI register.
• The DI register acts as the destination for string movement instructions.
IP (INSTRUCTION POINTER)
• The IP register contains the offset of the next instruction to be executed within the current code
segment.
• The IP and CS registers combine to form the complete address of the next instruction.
FLAGS (FLAG REGISTER)
• This is a special register with individual bit positions assigned to show he status of he
• CPU or the results of arithmetic operations.
• Each relevant bit is given a name and others are undefined.

EXERCISE 1.1 [5]


What is the register set on a 32-bitand 64-bit Intel machine?

9 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language


EXERCISE 1.2 [5]
Draw schematic for 32-bit and 64-bit Intel machine.

RESOURCES:
https://www.youtube.com/watch?v=wLXIWKUWpSs
https://www.tutorialspoint.com/assembly_programming/assembly_introduction.htm

10 Experiment 1 - Introduction to Microprocessor Lab and Assembly Language

You might also like