Académique Documents
Professionnel Documents
Culture Documents
Contents
Introduction Addressing modes Assembler directives Assembler directives types
Introduction
The MP communicates and operates in the binary system having 0 and 1 as bits. Each MP has a fixed set of instructions in the form of binary patterns called machine language. It is difficult for users to communicate in this binary language. Hence instructions are given abbreviated names called mnemonics which form the assembly language for a given MP. The mnemonic for a particular instruction consists of letters that suggest the operation to be performed by that instruction. An instruction is decided into groups of bits or fields, with one field called as operation code (opcode) indicating what the processor has to do and the other fields called operands, indicating the information needed by the instruction in carrying out its task.
Introduction
An operand may contain a datum, part of the address of a datum, an indirect pointer to a datum or other information pertaining to the data to be acted on by the instruction. Instructions may contain several operands but more the operands and longer the operands are, more memory space will be occupied and more time will be taken for execution. In order to minimize the total number of bits in an instruction, most instructions will have one operand in register. Memory and I/O spaces are relatively large and hence their address require several bits. But number of registers is small, hence it takes only few bits to specify a register. Therefore to conserve instruction bits, registers must be used as much as possible.
Addressing Modes
The way in which an operand is specified is called its addressing mode. 8086 has addressing modes for data and branch address separately. 8086 data addressing modes are: 1. Immediate 2. Direct 3. Register 4. Register indirect 5. Register relative 6. Based indexed 7. Relative based indexed 8086 branch addressing modes are: 1. Intrasegment direct 2. Intrasegment indirect 3. Intersegment indirect 4. Intersegment direct
Instruction Format
The general format of an assembler instruction is Label : Mnemonic operand2, operand1 Label it is an identifier that is assigned to the address of the first byte of instruction. Its presence is optional. Operand2 & operand 1 data on which operation to be performed. Operand 2 indicates destination and operand 1 indicates source.
Assembler Directives
There are some instructions in the assembly language which
are not a part of the processor instruction set.
Prepared by:Shruthi.K, Dept. of E&C, MIT.
These instructions are instructions to the assembler. These are referred to as pseudo operations or as assembler directives.
10
11
Assembler Directives
1. ASSUME used to instruct the assembler the name of the logical segment it should use for a specified segment. Ex: ASSUME CS: code, DS: data 2. DB(Define byte) used to declare a byte type variable or to set aside one or more memory locations of type byte in memory. Ex: temp DB 67h prices DB 45h,89h,23h temp DB 100 DUP(?) store DB 50 DUP(00h) 3. DW(Define word) instructs the assembler to define a variable of type word or to reserve memory locations of type word in memory. Ex: mul DW 437AH
12
Assembler Directives
4. DD (define double word) 5. DQ(define quad word) 6. DT(define ten bytes) 7.END it is put after the last instruction of a program to instruct the assembler that it is the physical end of the program. Ex: start: mov ax, bx add ax, bx END start 8. PROC instruction to assembler that next set of instructions form a procedure. 9. ENDP used along with the name of the procedure to indicate the end of a procedure to the assembler. Ex: display PROC near/far mov ax,bx ENDP display
13
Assembler Directives
10. SEGMENT used to indicate the start of a logical segment. 11. ENDS used with the name of a segment to indicate the end of that logical segment. Ex: data SEGMENT Temp DB 45h data ENDS 12. EQU(Equate) used to give name to some value. Each time the assembler finds the given name in the program, it replaces the name by the value assigned to it. Ex: data EQU 45h mov al,data (al = 45h)
14
Assembler Directives
13. INCLUDE used to instruct the assembler to insert a block of source code from the named file into the current source module. Ex: INCLUDE macro.lib 14. LENGTH instructs the assembler to determine the number of elements in some named data item such as an array or a string. Ex: data SEGMENT name DB 100 DUP(?) data ENDS code SEGMENT mov ax, LENGTH name (ax=100) code ENDS
15
Assembler Directives
15. OFFSET informs the assembler to determine the offset of a named data item from the start of the segment which contains it. Ex: data SEGMENT prices DB 12h,23h,34h data ENDS code SEGMENT mov BX, OFFSET prices code ENDS 16. ORG(Originate) the directive informs the assembler that the next code or data following the directive should be allocatted in the address mentioned with the directive. Ex: ORG 100h temp db 34h,67h,
16
Assembler Directives
17. PTR (pointer) used to explicitly specify the type of data being referred by a variable. Ex: data SEGMENT Array db 12h,23h,34h,45h data ENDS code SEGMENT mov BX, OFFSET Array Mov DL, BYTE PTR[BX] code ENDS 18.MODEL this directive provides shortcuts in defining segments. It initializes memory model before defining any segment. The memory model can be small, large, medium.
17
Assembler Directives
19. MACRO informs the assembler the beginning of the macro. 20. ENDM informs the assembler the end of the macro. Ex: macro name MACRO arguments ----------------ENDM
18