Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views20 pages

Assembly Introduction

Uploaded by

21st Tech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views20 pages

Assembly Introduction

Uploaded by

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

Assembly - Introduction

What is Assembly Language?

• A processor understands only machine language instructions, which are strings of


1's and 0's. However, machine language is too obscure and complex for using in
software development. So, the low-level assembly language is designed for a
specific family of processors that represents various instructions in symbolic code
and a more understandable form.

• Assembly language is a low-level programming language that is closely related to


the machine code instructions of a particular computer architecture
Assembly - Basic Syntax
Assembler directives, also known as pseudo-operations or pseudo-ops, are
instructions in assembly language that are not executed by the CPU but instead
provide instructions to the assembler itself.
Macros
Macros in assembly language are a way to define reusable code segments that can
be expanded inline wherever they are invoked.
They are similar to functions or procedures in high-level programming languages
but operate at the assembly language level.
Macros allow programmers to define custom instructions or sequences of
instructions, which can help improve code readability, maintainability, and
reusability.
Assembly - Memory Segments
Assembly - Registers
• General-purpose registers are used to store temporary data within the microprocessor
• A control register is a processor register that changes or controls the general behavior of a CPU or other
digital device. Common tasks performed by control registers include interrupt control, switching the
addressing mode, paging control, and coprocessor control.
• Segment registers are special-purpose registers used in x86 architecture processors to implement memory
segmentation. Memory segmentation divides the system's memory into segments of various sizes, each
identified by a segment selector value stored in one of the segment registers.
In x86 architecture, segment registers typically include:
1. CS (Code Segment): This register holds the segment selector for the current code segment, which contains the instructions being executed.
2. DS (Data Segment): This register holds the segment selector for the current data segment, used for general data operations.
3. ES (Extra Segment): This register holds the segment selector for an extra data segment, which can be used for additional data storage.
4. SS (Stack Segment): This register holds the segment selector for the stack segment, used for managing the call stack.
Assembly - Addressing Modes
Register Addressing
Register addressing provides fast access to data because registers are located within the processor itself and are
thus much faster to access compared to accessing data stored in memory.

MOV AX, BX ; Move the content of register BX to register AX

In this instruction, the content of register BX is moved (copied) to register AX.


Immediate Addressing
Immediate addressing is a type of addressing mode used in computer architecture and assembly language
programming where the operand of an instruction is a constant value or an immediate data. In this mode, the
instruction itself contains the actual data to be used in the operation.

• For example, in x86 assembly language, the MOV (move) instruction can be used with immediate addressing
like this:

MOV AX, 5 ; Move the immediate value 5 into register AX

In this instruction, the immediate value 5 is encoded directly into the instruction, and it is moved (copied) into
register AX.
Memory addressing
Memory addressing is a fundamental concept in computer architecture and assembly language programming. It
refers to the process of accessing data stored in memory by specifying the memory address where the data is
located. Memory addressing can be classified into several different addressing modes, each of which specifies
how the memory address is determined.
1. Direct Addressing: In direct addressing mode, the memory address of the operand is directly specified in
the instruction. For example:

MOV AX, [1234] ; Move the contents of memory location 1234 into register AX

In this instruction, the data stored at memory address 1234 is moved into register AX.
2. Indirect Addressing: In indirect addressing mode, the memory address of the operand is stored in a register
or another memory location, and the instruction indirectly accesses the data at that address. For example :

MOV BX, 1234 ; Load the memory address 1234 into register BX
MOV AX, [BX] ; Move the contents of the memory location pointed to by BX into register AX

In this example, the memory address stored in register BX (1234) is used to access the data stored at that
address.

You might also like