Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Assembly Language

Introduction

• Low level programming language

• Machine dependent

• A way of programming microprocessors

• A symbolic representation of machine code

1
Why

• Memory efficient

• Faster to run

• Flexible

3
How to

• Install DOSBOX

• Install assembler files

• Write assembly code (.asm)

• Create object file form source code

• Link the object files into an executable file

• Run program
4
But First…

• Memory segments

• Registers

• Addressing

5
Memory segments

• Areas defined in a program for containing data, code and stack.

• Code segment, Stack Segment, Data Segment

• Code Segment- an area in memory that stores the instruction codes

• Data Segment- a memory region where data elements are stored, static, alternate:
the .bss section- also a static memory section that contains data to be declared
later

• Stack Segment- contains data values passed to function and procedures.


6
Registers

• Internal memory storage location

• Data can be stored in memory or registers

• 3 groups of registers
• General Registers

• Control Registers
• Segment Registers
7
General Registers
• Further divided into 3
• Data Registers- four 32 bit registers used for arithmetic and logical operations.
AX- accumulator, used for IO and arithmetic operations

BX- base, used for indexed addressing

CX- counter, used to store loop count in iterative operations

DX- data, used for IO operations and arithmetic operations.

• Pointer Registers- three 32 bit registers


IP- Stores offset address of next instruction, used together with CS

SP- provides offset value within SS

BP-helps in referencing parameter variables passed to a subroutine procedure. Used with DI and SI

8
…General Registers

• Index Registers- used for indexed addressing and


sometimes in addition and subtraction. Two sets of 32 bit
index registers.
SI- source index
DI- destination index

9
Control Registers

• 32 bit IP register and 32 bit flag register together

• Many instructions change flag status and some others check


the value

• Ex: Overflow Flag, Direction Flag, Sign Flag, Zero Flag

10
Segment Registers

• Three main 16 bit segments


• CS- stores starting address of Code Segment
• DS- stores starting address of Data Segment
• SS- stores starting address of Stack Segment

• In addition to these we have the ES, FS, GS


11
Addressing
• Different addressing modes
 Immediate addressing
 Direct addressing
 Register addressing
 Register indirect addressing
 Indexed addressing mode
12
Syntax
• Statements

[label] mnemonic [operands] [;comment]

13

You might also like