ASSEMBLY LANGUAGE PROGRAMMING 1 ASSEMBLY LANGUAGE Assembly language
ASSEMBLY LANGUAGE PROGRAMMING 1
ASSEMBLY LANGUAGE Ø Assembly language is mnemonic PROGRAMMING representation of machine code Ø Ø Instruction has mnemonics (text form) Instruction decoder generates opcode Opcode is machine code It helps to learn internal architecture of computer Ø Programs requires less space in assembly language 2
Assembly Language Development MOV AX, BX. . . Loader OBJ Errors Linked Modules Main Memory 3 LIB
ASSEMBLER Ø Ø Ø MASM (Microsofts micro assembler) TASM (Borland Turbo assembler) NASM (Netwide assembler) It converts instructions into binary code It generates two files(. OBJ file and. LST file) Object file contains binary code of instruction and address of instruction Ø List file contains program statements, binary code of each instruction and offset of eachinstruction 4
LINKER Ø It is used to join many object files into one file Ø Large programs are divided into smaller files Ø Link file contains binary code of all combined modules Ø It produces. Exe file 5
LOADER Ø It is used to LOAD FILE in memory Ø It assigns specific address Ø It converts. EXE file into. BIN file which has physical address Ø EXE 2 BIN 6
Assembly Instruction Format Label : Mnemonics Operand 1, Operand 2 Label – Symbolic Name Assigned to First Byte of Instruction Mnemonics – Operation to be performed Operands – Operation to be performed on. Comments – Documentation, Non Executable. 7 ; Comments
Assembler Directives � These are not the part of processor instruction set. � Instructions to assembler, linker and loader. � Also referred as pseudo-operations. � They enable to control the way in which program assembles and lists. � Act during assembly of program and do not generate any machine executable code. 8
Classification �Segment Simplification �Data Allocation �Segment Related �Macros Declarations �Code label �Scope Declaration �Listing Control �Miscellaneous 9
Segment Simplification �. CODE : beginning of code segment ◦ Ex. CODE [name] �. DATA : beginning of code segment �. STACK : used for defining stack ◦ Ex. STACK [size] �. EXIT �. MODEL : used for selecting standard memory model ◦ Ex. MODEL [Memory model] 10
Memory Models Model No. of code segments No. of data segments Small One CS <=64 KB One DS<=64 KB Medium Any no. and any size One DS<=64 KB Compact One CS <=64 KB Any no. and any size Large Any no. and any size Huge Any no. and any size
Data allocation �DB �DW �DD �DQ �DT : define byte type of variable : define variable of 1 word length : define double word : define quad(4) word : define ten bytes (stores no in decimal form) �EQU : Equate �ORG : originate , it is used to set location pointer at desired location in program e. g. org 500 h 12
Segment related �SEGMENT : indicates start of logical segment �ENDS : indicates end of segment �END : last statement of program �ASSUME : used to tell assembler name of logical segment �GROUP : collect segment of same type under one name e. g. NAME GROUP SEG 1, SEG 2 13
scope �PUBLIC ◦ e. g. PUBLIC VAR 1, VAR 2 ◦ Var 1 and var 2 is to be referred from other module � EXTRN ◦ e. g. EXTRN SQRT : FAR ◦ Labels are in other module 14
Listing control �PAGE ◦ PAGE [length], [width] ◦ e. g. PAGE 10, 35 ◦ Maximum no of lines on a page ◦ Maximum no of characters in line �TITLE ◦ TITLE text ◦ e. g. TITLE MY FIRST PROGRAM 15
Code Label �ALIGN ◦ ALIGN number ◦ e. g. ALIGN 16 �EVEN ◦ e. g. EVEN NAME DB 5 DUP(0) �LABEL ◦ e. g. NEXT LABEL FAR �PROC ◦ procedure-name PROC type 16
Macro Declarations �MACRO and ENDM ◦ DISP MACRO MOV DL, AL MOV AH, 4 CH INT 21 H ◦ ENDM 17
Miscellenous �INCLUDE ◦ INCLUDE path: file name �NAME Assign name to each assembly module �GLOBAL ◦ GLOBAL variable-name 18
- Slides: 18