0% found this document useful (0 votes)
3 views17 pages

(ASM) Lab 3

The document provides an overview of Assembly Language, describing it as a low-level programming language that uses mnemonics for easier coding compared to machine language. It explains the structure of computer organization, focusing on main memory, CPU components, and the X86 architecture, including register types and their functions. Additionally, it discusses memory modes in the 8086 microprocessor, detailing the roles of various registers and how they interact with memory addresses.

Uploaded by

amanyhassan557
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
0% found this document useful (0 votes)
3 views17 pages

(ASM) Lab 3

The document provides an overview of Assembly Language, describing it as a low-level programming language that uses mnemonics for easier coding compared to machine language. It explains the structure of computer organization, focusing on main memory, CPU components, and the X86 architecture, including register types and their functions. Additionally, it discusses memory modes in the 8086 microprocessor, detailing the roles of various registers and how they interact with memory addresses.

Uploaded by

amanyhassan557
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/ 17

1

Assembly Language
Lab (3)
Agenda

 What is Assembly Language?


 Computer Organization
 Main memory
 X86 Architecture
What is Assembly Language? 3

 Assembly Language is a low-level (machine‐level) programming


language that uses mnemonics instead of numeric codes (0’s, 1’s) to
simplify programming.

 For example, the instruction in machine language which means copy


the content from AX register to BX register is:
8B D8

While same instruction written in assembly is:


mov BX, AX

 Each statement in assembly code has a one-to-one relationship with


machine language instructions, in other words each statement
corresponds to a single machine code instruction.
What is Assembly Language? 4

 To run a program written in assembly language, we should have a


converter (or translator) which converts these labels and mnemonics
to their corresponding machine codes in 0’s and 1’s. This converter is
called an assembler.

Assembly Code Assembler Machine Code

To run a program
written in a high level
language we should
have a converter
called …..?
Computer Organization

CPU

Main Control
ALU
Memory unit

R1 R2 R3 R4
Special Purpose
(Segment) Register
Main Memory

 It is the place to store data (and instructions) temporarily.


 Each location (byte) in memory has content (value) and a
unique label (address).
 Often, memory is used in larger chunks than single bytes. As
shown below:

Byte
Main
Memory
Memory Modes:
Real Mode (8086) – 16 Bit Registers

CPU 8086

Register Size 16 bits

20
Main Memory 1 MByte (2 𝑏𝑦𝑡𝑒)

Program Segment 64 k
Memory Modes:
Real Mode (8086) – 16 Bit Registers

 4 General Purpose ▪ 4 Segments registers


 AX : Accumulator ▪ DS: Data Segment.
 BX : Base ▪ CS: Code Segment
 CX: Count
▪ SS: Stack Segment
 DX: Data
▪ ES: Extra Segment

 4 Index and Pointers ▪ Instruction Pointers


 DI: Destination Index
▪ IP: Instruction Pointer
 SI : Source Index
 BP: Base Pointer
 SP : Stack pointer
▪ Flags
▪ ZF , SF, OF, CF...
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 4 General Purpose
Each of these registers could be decomposed into two 8‐bit registers.

AH and AL are dependent on AX. Changing AX’s value will change


AH and AL values and vice versa.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 Index and Pointers (SI, DI)
They are often used as pointers to memory items, but can be used for
other purposes as the general‐purpose registers. They cannot be
decomposed into 8‐bit registers.
Memory Modes:
Real Mode (8086) – 16 Bit Registers
 Index and Pointers (BP, SP)
They are used to point to data in the stack and are called the Base
Pointer and Stack Pointer, respectively.

SP

Stack
BP
 Pointers and Index Registers
 The pointers will always store some address or memory
location. In 8086 Microprocessor, they usually store the
offset through which the actual address is calculated.
1. Instruction Pointer (IP):
The instruction pointer usually stores the address of the next
instruction that is to be executed. Apart from this, it also acts as
an offset for CS register.
2. Base Pointer (BP):
The Base pointer stores the base address of the memory. Also,
it acts as an offset for Stack Segment (SS).
► Stack Pointer (SP):
The Stack Pointer Points at the current top value of the Stack. Like the
BP, it also acts as an offset to the Stack Segment (SS).
The indexes are used with the extra segment and they usually are used
for copying the contents of a particular block of memory to a new
location.
1. Source Index (SI):
It stores the offset address of the source.
2. Destination Index (DI):
It stores the offset address of the Destination.
Memory Modes:
Real Mode (8086) – 16 Bit Registers

▪ 4 Segments registers (CS, DS, SS, ES)


They keep the starting address of memory chunk used for
different parts of a program.

CS stands for Code Segment,


DS for Data Segment,
SS for Stack Segment, and
ES for Extra Segment. ES is used as a temporary segment register.
Memory Modes:
Real Mode (8086) – 16 Bit Registers

 Examples:
1. Segment Register: 047C
Offset Register: 0048
Physical address: 047C0 + 0048 = 04808 Same
address!

2. Segment Register: 047D


Offset Register: 0038
Physical address: 047D0 + 0038 = 04808
And we can also get the same address when we add 047E0
with 0028.

You might also like