• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Assembly Language -I

on

  • 5,047 views

 

Statistics

Views

Total Views
5,047
Views on SlideShare
5,032
Embed Views
15

Actions

Likes
0
Downloads
217
Comments
0

1 Embed 15

http://wiki.opendesignstrategies.org:8040 15

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Name : refers to address of data iteme.g. : COUNTER DB 0 which tells that whenever COUNTER word strikes, memory will “define Byte” with initial value 0Label: refers to address of instruction, procedure, or segmente.g. : B30: ADD BL,25
  • MOV : Internally, it cannot transfer data directly b/w source and destination that both resides in external memory.Ask mam that how it operates.
  • Write down operations from other ppts

Assembly Language -I Assembly Language -I Presentation Transcript

  • AssemblyLanguage -I
    Submitted by : DevikaRangnekar
    Rupam
    JaspreetKaur
    MCA – I (Morning)
    Rollno : 9
    30
    15
    Submitted to : Ms. InduChabbra
    Free Powerpoint Templates
  • Assembly Language
    A Language that allows instruction and storage locations to be represented by letters and symbols instead of binary numbers is called Assembly Language or Symbolic Language.
  • INSTRUCTION SET
  • Instruction Set
    DIRECTIVE:
    • Also called Pseudo- Instruction
    • Tells assembler to perform specific action.
    INSTRUCTION:A set of statements that assembler translates into object code.
    FORMAT for INSTRUCTION
  • Format for Instruction
    IDENTFIER:Name or Label that you give to a data item or an instruction.
    OPERATION:reserved symbols that correspond to instructions
    ex: ADD, MOV,SUB,AND, LD, LDR, …
    OPERAND :Data on which the operation is to be performed.
    • Registers -- specified by Rn, where n is the register number
    • Numbers -- indicated by # (decimal) or x (hex)
    • Label -- symbolic name of memory locations
    ex: ADD R1,R1,#3
  • Source and Destination
    Source operands can be:
    Register/Memory reference/Immediate value
    Destination operands can be:
    Register/Memory reference
    Note:
    The Intel CPU does NOT allow both source and destination operands to be memory references
  • Examples of Instruction Set
    DIRECTIVE:
    COUNT DB 1;
    INSTRUCTION:
    MOV AX, [0x00040222h]
    Can also have register names instead of hex addresses e.g. MOV AX, [EBX]
    COUNT will define a byte with initial value 1
    Contents of memory location 0x00040222
    Refers to the contents of register EBX
  • Types of Instructions
  • Data Transfer Instruction
  • Data Transfer Instructions
  • Arithmetic Instructions
  • Arithmetic Instructions
  • Contd…
  • Logic Instruction
  • Logic instructions
    EXAMPLE: Let AX=1010 BX=0111
    AND BX,AX
    BX=0010
    1010
    .0111
    0010
  • Shift Instrun.Rotate Instrun.
  • EXAMPLES
    SHIFT INSTUCTION
    SHL BH,1 ;shift 1 bit left
    BH :00001010
    OUTPUT:
    ROTATE INSTRUCTION
    ROL BH,1 ; rotate 1 bit left
    BH: 10110111
    OUTPUT:
    LOST
    INCLUDED
  • OPERATORS
  • ARITHMETIC OPERATORS
    These operators include the arithmetic signs and perform arithmetic during the assembly.
  • LOGICAL OPERATORS
    • The LOGICAL operators process the bits in an expression.
    • EXAMPLE:
    MOV CL,00111100B AND 01010101B ; CL= 00010100B
    MOV DL,NOT 01010101B ; CL=10101010B
  • High/Highword & Low/Lowword Operators
  • SHL and SHR Operators
    • The operators SHL(shift left) and SHR (shift right) shift an expression during an assembly.
    • FORMAT:
    expression SHL/SHR count
    • EXAMPLE:
    MOV BL,01011101B SHR 3 ; Load 00001011B
  • OFFSET OPERATOR
    • The OFFSET operator returns the offset address of a variable or label.
    • OFFSET : the distance in bytes from the segment address to another location within the segment.
    • CODED AS :
    offset variable/label
    • EXAMPLE:
    MOV DX,OFFSET PART_TBL ; return offset address of part_tbl
  • PTR OPERATOR
    • Provides flexibility to access part of a variable.
    • Can also be used to combine elements of smaller type.
    • Used to override the default type of variable.
    SYNTAX:
    type ptr expression
    Example :
    .data
    Dval dword 12345678h |<------ DVAL ------- |  -----------ARRAY-----
    Array byte 00h,10h,20h,30h
    .code
    Moval,dval;error
    Moval, byte ptr dval ;al=78h
    Mov ax, dval ;error
    Mov ax, word ptr dval ;ax=5678h
    Mov eax ,array ;error
    Mov eax, dword ptr array ;eax=30201000h
  • DUP OPERATOR
    • USED: to generate multiple bytes or words with known as well as un-initialized values.
    • PURPOSE:to tell the assembler to duplicate or repeat the data definition directive a specific number of times.
    • EXAMPLE:
    var1 BYTE 20 DUP(0) ; 20 bytes of zero
    var2 BYTE 20 DUP(?) ; 20 bytes uninitialized
    var3 BYTE 10, 3DUP(0) , 20 ; 5 bytes 10,0,0,0,20
    • The (?) with the dup means that storage allocated by the directive is uninitialized or undefined.
    • The assembler allocates the space but does not write in it. Use ? for buffer areas or variables your program will initialize at run time.
  • SEG OPERATOR
    • The seg operator does two things :
    Returns the address of the segment in which a specified variable or label is placed.
    It converts the type of the specified expression from address to constant.
    • Coded As:
    seg variable/label
    • Example :
    MOV AX,SEG WORDA ; Get address of data seg
    MOV AX,SEG A10BEGIN ; Get address of code seg
  • INDEX OPERATOR
    • Add a constant to a register to generate an offset.
    • Allows to reference a members in an array.
    • Uses square brackets[ ] and acts like a plus(+) sign.
    • Two equivalent forms:
    constant[ reg ]
    [constant + reg ]
    EXAMPLE:
    part_tbl DB 25 DUP(?) ;Defined table
    MOV CL<PART_TBL[4] ;accessing 5th entry
    MOV DX,[BX] ; offset address in base reg DS:BX
    MOV[BX+SI+4],AX ;base+index+constant
    • The LENGTHoperator returns the number of entries defined by a DUP operator.
    • EXAMPLE :
    PART_TBL DW 10 DUP(?)
    MOV DX,LENGTH PART_TBL
    • If the referenced operand does not contain a DUP entry, the operator returns the value 01.
    LENGTH OPERATOR
  • TYPE OPERATOR
    • The TYPE operator returns the number of bytes, according to the definition of the referenced variable.
    • CODED AS:
    TYPE variable/label
  • SIZE OPERATOR
    • Returns the number of bytes taken up by a structure
    • Basically, LENGTH * TYPE
    • Coded As:
    SIZE variable
    • Example :
    BYTEA DB? ;Define one byte
    PART_TBL DW 10 DUP(?) ;Define 10 words
    MOV AX,TYPE BYTEA ;AX=0001H
    MOV AX,TYPE PART_TBL ;AX=0002H
    MOV CX,LENGTH PART_TBL ;CX=000AH(10)
    MOV DX,SIZE PART_TBL ;DX=0014H(20)
  • EXECUTION OF ASSEMBLY PROGRAM
  • Execution of an Assembly Lang. Program
    Includes following steps:
  • ASSEMBLING, LINKING AND EXECUTING
  • EDITOR
    EDIT
    PROG.
    ASM
    ASSEMBLER
    ASSEMBLE
    PROG.
    OBJ
    LINKER
    LINK
    PROG.
    EXE
    EXECUTE
  • EDITING A PROGRAM
  • ASSEMBLING SOURCE PROGRAM
  • LINKING AN OBJECT PROGRAM
  • EXECUTING A PROGRAM
    Having assembled and linked a program, we can now execute it .
    If the .EXE file is in the default drive, you could ask the loader to read it into memory for execution by typing
    C:TASMBIN>PROG.EXE
  • STEPS TO CREATE AND RUN A PROGRAM