Assembly language features by chiragprmr

VIEWS: 78 PAGES: 3

More Info
									Assembly language features:

Program comments:

A comment can appear on a line by itself and start with (;)

Reserved words:

Certain names in assembly language are reserved for their own purposes. To be used only
under special conditions.
Categories of reserved word are:
    Instructions: operations that the computer can execute.
    Directives: provide information to the assembler.
    Operators: used in expressions.
    Predefined symbols: return information to program during the assembly.


Identifiers:

Is a name that you apply to an item in program that can be referenced.
Two types of identifiers are:
     Name: refers to the address of a data item.
     Label: refers to address of an instruction, procedure, or segment.

Some rules apply to identifiers are:

Category             Allowable characters
Alphabetic letters   A-Z, a-z
Digits               0-9 (not the first character)
Special characters   ?, break, _, $, @
                     „, . (not first character)

Statements:

Two types of statements are:
   Instructions: assembler translates to object code.
   Directives: tell assembler to perform certain action.

Format of a statement is:

[identifier] operation [operand(s)] [; comment].

Example:
             Identifier        operation      operand         comment
Directive: COUNT                DB            1               ; name
Instruction: L30:              MOV           AX, 0            ; label
Directives:

    Generates no m/c executable code.
    Control the way in which a source program assembles and lists.
    SEGMENT: define start of the segments.
        o Segment-name SEGMENT
        o Segment-name ENDS
        o ENDS end the segment.
    END: ends entire program.
    ASSUME: it is required to tell assembler the purpose of each segment in the
     program.
        o ASSUME CS: code segment, DS: data segment.



Defining data types:

Format for data definition is:

[name] Dn expression

Name: a program that references a data item by means of name.
Directive (Dn): DB, DW, DD, DF, DQ, DT indicate length of the data item.
Expression: specify uninitialized (?) or constant value.
       Datax DB ?              ; uninitialized item
       Datax DB 25             ; initialized item
       Datax DB 21, 22, 23, 24. . . . . . . . . ; multiple items.
       Datax DW 10 DUP(?) ; Ten words, uninitialized.
       Datax DB 5 DUP(12) ; five bytes containing 12.
       Datax DB 3 DUP(5 DUP(4)) ; fifteen 4s.
       Datax DB “hello world”


Definition     Conventional directive   Masm 6.0 directive
Byte           DB                       BYTE
Word           DW                       WORD
Doubleword     DD                       DWORD
Farword        DF                       FWORD
Quadword       DQ                       QWORD
Tenbytes       DT                       TBYTE


Operators:

Index:
    Used for indirect addressing..
    Uses square brackets.
    Temp DB 25 DUP(?)
    MOV CL, Temp[4] ; get fifth entry (byte 6).

Length:
    Returns no of entries defined by a DUP operator.
    Temp DW 10 DUP(?)
    MOV DX, LENGTH Temp ; return length 10 to DX.

Offset:
    returns the offset address of a variable or label.
    MOV DX, OFFSET Temp ; returns the offset address of temp.

PTR:
      specify a size in ambiguous operand or to override the defined type for variable.
      Type PTR expression.
      Temp DB 22H
             DB 35H
      MOV AX, WORD PTR Temp ; move two bytes (2235) to AX

								
To top