Академический Документы
Профессиональный Документы
Культура Документы
* Following are the Data Transfer Types: 1. Move contents of a register, or contents of a memory location, or immediate data to register or memory location. 2. Data transfer between a segment register and a register. 3. PUSH & POP instructions 4. Exchange instructions. 5. Data transfer with I/O ports
Explanations/Example
Copy a byte or a word Both source and destination should be of same type (byte or word) Ex. MOV AX,BX, MOV CL,0F2H, MOV AX,25H; MOV WORD PTR 0F2H[BP],34H MOV DS,BX Push the contents of register onto stack top Ex. PUSH SI, PUSH DS, PUSH AX Pop to a register from stack top Ex. POP SI, POP DS, POP AX Push the contents of FLAG register onto the stack top Pop the stack top to the FLAG register Exchange Interchange the contents of two registers Ex. ECHG AX,SI, XCHG BX,43h[SI] Translate Translate byte from one code to another code Ex. MOV BX,ASCII_TABLE XLAT B This will require data in AL with ASCII from the lookup table.
2 3 4 5 6 7
PUSH PUSH [source] POP POP Destination PUSHF POPF XCHG XCHG [Dest.], [Source] XLAT OR XLATB XLAT
Explanations/Example
Load effective Address Loads effective address of a memory location into a register Ex. LEA BX,83H[SI],LEA DX,MSG1 Load register and DS with words from memory. (REG) Source (DS) Source + 2 Ex. LDS SI,[200] LDS BX,82H[SI] Load registers and ES with words from memory. (REG) source (ES) source + 2 Ex. LES AX, [12345] LES BX,42H[SI] Load AH with LS byte of FLAG Register LS of FLAG register. S Z U A U P U C (AH) Store AH contents in the LS byte of FLAG register. S Z U A U P U C (AH)
11
12
13
14
Arithmetic Group
15 16 AAA AAA DAA DAA ASCII adjust for addition. Ex. ADD AL, BL; if AL+BL=67H, then AAA; AL contains 07H Decimal adjust AL after BCD addition. DAA operates only on [AL] register Ex. ADD AL, BL; 59+34=>8DH DAA; Adds O6 to AL as lower nibble value is greater than 9 Negate (Forms 2's complement). Ex. NEG BX; Replaces word in BX with its 2's complement ASCII adjust for subtraction. Ex. SUB AL, DL; 34H-38H=>FCH in AL AAS; As lower nibble C is greater than 9 it subtracts 6 from AL and CF is set.
17 18
Instruction/Syntax
19 DAS DAS
Explanations/Example
Decimal adjust AL after BCD subtraction. If lower nibble after subtraction is greater than 9, then subtract 6 from AL (OR if CF is set) Ex. SUB AL, BL; 78H-93H=>E5 with DAS; borrow, CF is set BCD adjust after multiplication. Ex. MUL BL; AL*BL=AX (Say 0020H) AAM; AX=0302H Convert signed byte to signed word CBW produces a double length dividend from a byte prior to performing division. Convert signed byte to signed double word. CWD produces a double length dividend from a word prior to performing division. BCD to binary convert before division. AAD converts two unpacked BCD digits in AH & AL to the equivalent binary number
20
AAM AAM
21 22 23
Logical Instructions
24 TEST TEST [Dest.], [Source] AND operands to update flags. TEST instruction performs logical AND of two operands, updates flag, but does not return result i.e. neither operand is changed. Ex. TEST SI, DI TEST AL, 0100 0100b Rotate operand around to the left through carry.
LSB Cy MSB
25
26
By default CL register is used. Ex: RCL AL, CL Rotate operand around to the right through carry.
LSB Cy MSB
Instruction/Syntax
27 SHL / SAL SHL/SAL [Opr], [Cnt]
Explanations/Example
Shift logical left / shift Arithmetic left. 0
Cy MSB LSB
28
29
Branch Instructions
30 31 32 CALL RET JMP Call procedure Return from procedure Jump to specified location
* All the BRANCH instructions must have a single operand specifying the location where to branch. Generally we use LABELS to jump to that particular location depending on the condition instead of specifying the exact memory location.
Instruction/Syntax
41 42 INT INT [Interrupt type] IRET
Explanations/Example
Interrupt program execution. Int. type number should be 00H to FFH Ex: INT 01H, INT 21H Interrupt Return IRET transfers control back to the point of interruption by popping IP, CS & flags from the stack.
53
LOCK
String Instructions
Register SI & DI must be initialized to point to the source & destination strings before executing the string instructions. 54 MOVS MOVS [Dest.],[Source] Or MOVSB / MOVSW Move string byte or string word. Transfers a byte or word from source string to destination string. Ex: MOVSB ;Move (DI) (SI)
Instruction/Syntax
55 CMPS CMPS [Dest.],[Source] Or CMPSB / CMPSW SCAS SCAS [Dest_Str] OR SCASB,SCASW
Explanations/Example
Compare string byte or string word. It compares byte/word of one string with byte/word of another string. Flags affected CF, SF, IF Ex: CMPS Str1, Str2 Scan a string byte or string word. SCAS compares byte AL or word in AX with a byte or word pointed by DI in ES.Destination has to be in ES.SCAS updates FLAGS but doesnot alter destination string or accumulator. EX. SCAS Input_str, LEA DI,BOFF1 MOV AL,ODH SCASB Load string byte in AL or load string word in AX.LODS transfers the byte or word string element addressed by SI to register AL or AX. EX. MOV SI,Offset source_str CLD LODSB Store byte or word in string STOS transfers a byte or word from register AL or AX to the string element addressed by DI. EX. MOV DI,Offset atr1 CLD MOV AX,00H STOSW Load string byte in AL or load string word in AX.LODS transfers the byte or word string element addressed by SI to register AL or AX. EX.MOV SI,Offset source_str CLD LODSB Store byte or word in string STOS transfers a byte or word from register AL or AX to the string element addressed by DI. EX. MOV DI,Offset atr1 CLD MOV AX,00H STOSW Repeat string instruction until specified condition exists. EX. LEA SI,Service_str LEA DI,Dest_str MOV CX,20H CLD REP MOVSW
56
57
58
59
60
61
REP REP
Instruction/Syntax
62 REPE / REPZ
Explanations/Example
Repeat while equal/Repeat while not zero. This will cause string instructions to be repeated as long as ZF = 0 & CX != 0. EX. LEA DI,Str1 MOV AL,ODH CLD MOV CX,25H REPE SCASB Repeat while not equal/Repeat while not zero. This will cause string instructions to be repeated as long as ZF = 0 & CX != 0 EX. MOV DI,Offset Str1 MOV CX,100H CLD RPNE SCASW
63
REPNE / REPNZ