1 / 11

Assembly Language

Assembly Language. Data Transfer Instructions. The MOV instruction. The MOV instruction copies data from one operand to another using either 8-bit or 16-bit operand. Syntax: MOV destination, source

acolleen
Download Presentation

Assembly Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assembly Language Data Transfer Instructions

  2. The MOV instruction • The MOV instruction copies data from one operand to another using either 8-bit or 16-bit operand. • Syntax: • MOV destination, source • Data is merely copied from the source to the destination, so the source operand is not changed. • The source operand may be immediate data, a register, or a memory operand. • The destination operand may be a register or a memory operand. Data Transfer Instructions

  3. The MOV instruction • The following types of data transfers are possible: Immediate data to register or memory register to register register to memory memory to register • Register operands • A move involving only registers is the fastest type. • Registers should be used when an instruction must execute quickly. • Any registers may be used as a source operand, and any register except CS and IP may be destination operands, • Mov ax,bx • Mov dl, al • Mov bx,cs Data Transfer Instructions

  4. The MOV instruction • Immediate operands • An immediate value (integer constant) may be moved to any register (except a segment register or IP) & may be moved to any memory operand. • A common error is to make the immediate value larger than the destination operand. • Mov bl, 01 ; move 8-bit value to BL • Mov bx, 01 ; mov 16-bit value to BX • Mov bx, 1000h ; mov 16-bit value to BX • Mov total, 1000 ; mov16-bit value to a variable Data Transfer Instructions

  5. The MOV instruction • Direct addressing • A variable may be one (but not both) of the operands in a MOV instruction • The content of the variable are either the source or destination of the move. • Count is an 8-bit variable which contains the number 1. • The following statement copies the contents of count into AL: mov al, count Count: (AL register) 01 01 Data Transfer Instructions

  6. The MOV instruction • Mov al, count ; 8-bit memory to register • Mov total, ax ; 16-bit register to memory • Mov total, 1000h ; 16-bit immediate to memory Data Transfer Instructions

  7. The MOV instruction • There are a few limitations on the type of operands (which are based on both the physical design of the processor and its instruction set): • CS and IP may never be destination operands • Immediate data and segment registers may not be moved to segment registers • The source and destination operands must be the same size. • If the source is immediate data, it must not exceed 255(FFh) for an 8-bit destination or 65,535 (FFFFh) for a 16-bit destination. • Memory to memory moves is not allowed Data Transfer Instructions

  8. The MOV instruction • Samples of illegal moves: • mov word_1, word_2 ; memory to memory • mov ds, 1000h ; immediate to segment • mov ip, ax ; IP as destination • mov al, bx ; mismatching register types • mov 1000h, ax ; immediate data as destination Data Transfer Instructions

  9. The XCHG instruction • The XCHG instruction exchanges the contents of two registers or of a register and a variable. • Syntax: • XCHG operand 1, operand 2 • The two operands may be registers or memory operands, as long as one operand is a register. Data Transfer Instructions

  10. The XCHG instruction • The XCHG instruction is the most efficient way to exchange two 8-bit or 16-bit operands because you don’t need a third register or variable to hold a temporary value. • This instruction provides a speed advantage (especially in sorting applications). • One or both operands may be registers or a register may be combined with a memory operand. • Two memory operands may not be used together. Data Transfer Instructions

  11. The XCHG instruction • Xchg ax, bx ; exchange BX with AX • Xchg ah, al ; exchange upper, lower register halves. • Xchg var1, bx ; exchange memory operand with BX Data Transfer Instructions

More Related