Download presentation
Presentation is loading. Please wait.
1
Assembly language
2
What is Assembly language
It’s a programming language consist of a series of instructions using registers every instruction converted to machine language 0, 1
3
Assembler Assembler: Is the program translate instructions from assembly language to machine language.
5
Advantages of Assembly Language
An understanding of assembly language provides knowledge of: - Interface of programs with OS, processor and BIOS; - Representation of data in memory and other external devices; - How processor accesses and executes instruction; - How instructions accesses and process data; - How a program access external devices. Other advantages of using assembly language are: - It requires less memory and execution time; -It allows hardware-specific complex jobs in an easier way;
6
Addressing Data in Memory
the processor controls the execution of instructions is referred as the fetch-decode execute cycle, or the execution cycle. It consists of three continuous steps: 1Fetching the instruction from memory 2 Decoding or identifying the instruction 3 Executing the instruction
7
The processor may access one or more bytes of 0725Hmemory at a time.
Let us consider a hexadecimal number. This number will require two bytes of memory. The high-order byte or most significant byte is 07 and the low order byte is 25. The processor stores data in reverse-byte sequence i.e., the low-order byte is stored in low memory address and high-order byte in high memory address. So if processor brings the value 0725H from register to memory, it will transfer 25 first to the lower memory address and 07 to the next memory address.
8
example
9
x: memory address When the processor gets the numeric data from memory to register, it again reverses the bytes. There are two kinds of memory addresses: 1 An absolute address - a direct reference of specific location. 2 The segment address (or offset) - starting address of a memory segment with the offset value
10
Assembly Basic Syntax An assembly program can be divided into
three sections: 1-The data section 2-The text section 3-The global section
11
The syntax for declaring data section is: .data
The data section is used for declaring initialized data or constants. This data does not change at runtime. You can declare various constant values, file names or buffer size etc. in this section. The syntax for declaring data section is: .data
12
The text section Define the code segment of a program
containing instructions
13
.Global directive -Declares a symbol as global
-We use this directive to declare main .procedure of program
14
Example: ######data segment### .Data . ##########code segment######## .text .global main Main: .. Li $v0,10 #exit program syscall
15
Assembly Language Instructions
-build from two pieces Add R1,R3,3 Opcode What to do with the data (ALU operation) Operands Where to get data and put the results
16
Types of Opcodes Arithmetic, logical Memory load/store
add, sub, mult and, or Cmp Memory load/store ld, st Control transfer jmp bne Complex movs
17
Operands Each operand taken from a particular addressing mode:
Examples: Reflect processor data pathways
18
Types of Assembly Languages
Assembly language closely tied to processor architecture At least four main types: CISC: Complex Instruction-Set Computer RISC: Reduced Instruction-Set Computer DSP: Digital Signal Processor VLIW: Very Long Instruction Word
19
CISC Assembly Language
Developed when people wrote assembly language Complicated, often specialized instructions with many effects Examples from x86 architecture String move Procedure enter, leave Many, complicated addressing modes So complicated, often executed by a little program (microcode)
20
RISC Assembly Language
Response to growing use of compilers Easier-to-target, uniform instruction sets “Make the most common operations as fast as possible” Load-store architecture: Arithmetic only performed on registers Memory load/store instructions for memory- register transfers Designed to be pipelined
21
DSP Assembly Language Digital signal processors designed specifically for signal processing algorithms Lots of regular arithmetic on vectors Often written by hand Irregular architectures to save power, area Substantial instruction-level parallelism
22
VLIW Assembly Language
Response to growing desire for instruction- level parallelism Using more transistors cheaper than running them faster Many parallel ALUs Objective: keep them all busy all the time Heavily pipelined More regular instruction set Very difficult to program by hand Looks like parallel RISC instructions
23
Example: Euclid’s Algorithm
In C: int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; Two integer parameters One local variable Remainder operation Non-zero test Data transfer
24
i386 Programmer’s Model eax cs Mostly general-purpose registers Code
31 15 eax cs Mostly general-purpose registers Code ebx ds Data ecx ss Stack edx es Extra fs Data esi Source index gs Data edi Destination index ebp Base pointer Segment Registers: Added during address computation esp Stack pointer eflags Status word eip Instruction Pointer (PC)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.