Anda di halaman 1dari 6

Rotate Instructions

1. ROL
Instruction: ROL Rotate Left
Function: Rotate all bits of operand left
Syntax: ROL Destination, Count
Sample Instruction: XCHG AX, BX
Example before execution: AX = 2017 BX = 3016
Example after execution: AX = 3016 BX = 2017

2. ROR
Instruction: ROR Rotate Right
Function: Pushes data on top of the stack
Syntax: PUSH REG
Sample instruction: MOV AX, 2017H
PUSH AX
Example before execution: 3016H
2017H
Example after execution: 2017H
3016H

3. RCL
Instruction: RCL Rotate Left through Carry
Function: Takes the data out of the top of the
stack
Syntax: POP REG
Sample Instruction: MOV AX, 2017H
PUSH AX

Example before execution: 2017H


3016H
Example after execution: 3016H

4. RCR
Instruction: RCR Rotate Right through Carry
Function: Takes the data out of the top of the
stack
Syntax: POP REG
Sample Instruction: MOV AX, 2017H
PUSH AX

Example before execution: 2017H


3016H
Example after execution: 3016H

Flag Control Instructions


1. LAHF
Instruction: LAHF Load Ah from flags
Function: Add both source operand and the contents
of the carry flag to a destination operand
Syntax: ADC REG, REG
Sample Instruction: MOV AX, 7; CF = 1 AX = 7
ADC AX, 1:
Example before execution: AX = 7
Example after execution: AX = 9

2. SAHF
Instruction: SAHF Store Ah into flags
Function: Corrects the result of subtraction of two
packed BCD values
Syntax: DAA
Sample Instruction: MOV AL, 0Fh
DAA
Example before execution: AL = 0Fh (17)
Example after execution: AL = 17h

3. CLC
Instruction: CLC Clear Carry Flag
Function: Corrects the result in AH and AL after
addition when working with BCD values.
Syntax: AAA
Sample Instruction: MOV AX, 17
AAA
Example before execution: AH = 00, AL = 0Fh
Example after execution: AH = 01, AL = 07

4. STC
Instruction: STC Set Carry Flag
Function: Same as subtraction, except that the CF,
which holds the borrow, also subtracts from
the difference.
Syntax: SBB AX, BX
Sample Instruction: MOV AX, 7
SBB AL, 5; AX = 7-5-1
Example before execution: AX = 7
Example after execution: AX = 1

5. CMC
Instruction: CMC Complement Carry Flag
Function: Corrects the result of subtraction of two
packed BCD values.
Syntax: DAS
Sample Instruction: MOV AL, 0FFh; AL = 0FFh (-3)
DAS
Example before execution: AL = 0FFh (-3)
Example after execution: AX = 99h CF = 3

6. PUSHF
Instruction: PUSHF Push Status Register onto Stack
Function: Corrects the AH and AL after subtraction
when working with BCD values.
Syntax: AAS
Sample Instruction: MOV AX, 02FFh
AAS
Example before execution: AH = 02, AL = 0FFh
Example after execution: AH = 01 AL = 09

7. POPF
Instruction: Pop Flags off the Stack
Function: Corrects the result of subtraction of two
packed BCD values
Syntax: DAA
Sample Instruction: MOV AL, 0Fh
DAA
Example before execution: AL = 0Fh (17)
Example after execution: AL = 17h

8. CLI
Instruction: CLI Clear Interrupt Flag
Function: Corrects the result in AH and AL after
addition when working with BCD values.
Syntax: AAA
Sample Instruction: MOV AX, 17
AAA
Example before execution: AH = 00, AL = 0Fh
Example after execution: AH = 01, AL = 07

9. STI
Instruction: STI Set Interrupt Flag
Function: Same as subtraction, except that the CF,
which holds the borrow, also subtracts from
the difference.
Syntax: SBB AX, BX
Sample Instruction: MOV AX, 7
SBB AL, 5; AX = 7-5-1
Example before execution: AX = 7
Example after execution: AX = 1

10. CLI
Instruction: CLI Clear Interrupt Flag
Function: Corrects the result in AH and AL after
addition when working with BCD values.
Syntax: AAA
Sample Instruction: MOV AX, 17
AAA
Example before execution: AH = 00, AL = 0Fh
Example after execution: AH = 01, AL = 07

11. STI
Instruction: STI Set Interrupt Flag
Function: Same as subtraction, except that the CF,
which holds the borrow, also subtracts from
the difference.

Syntax: SBB AX, BX


Sample Instruction: MOV AX, 7
SBB AL, 5; AX = 7-5-1
Example before execution: AX = 7
Example after execution: AX = 1

12. CLD
Instruction: CLD Clear Direction Flag
Function: Same as subtraction, except that the CF,
which holds the borrow, also subtracts from
the difference.
Syntax: SBB AX, BX
Sample Instruction: MOV AX, 7
SBB AL, 5; AX = 7-5-1
Example before execution: AX = 7
Example after execution: AX = 1

13. STD
Instruction: STD Set Direction Flag
Function: Corrects the result in AH and AL after
addition when working with BCD values.
Syntax: AAA
Sample Instruction: MOV AX, 17
AAA
Example before execution: AH = 00, AL = 0Fh
Example after execution: AH = 01, AL = 07

Control Transfer Instructions


1. CALL
Instruction: CALL Subroutine call
Function: Makes operand negative (twos complement).
Syntax: NEG REG
Sample Instruction: MOV AL, 7; AL = 07h
NEG AL
Example before execution: AL = 07h
Example after execution: AL = 0Fbh (-7)

2. RET
Instruction: RET Return Instruction
Function: The bitwise AND operation returns 1, if the
matching bits from both the operands are 1,
otherwise it returns 0.
Syntax: AND DESTINATION, SOURCE
Sample Instruction: AND AH, AL
Example before execution: AH = 0101
AL = 0011
Example after execution: AH = 0001

Conditional Jump and Loop Instructions


1. JCXZ
Instruction: JCZX Jump if Cx = 0
Function: Shift bits left in an unsigned byte, word
or doubleword in a register or memory.
Shift all bits left, the bit that goes off
is set to CF.
Syntax: SHL memory, immediate
Sample Instruction: SHL, AL, 1
Example before execution: AL = 10101111
Example after execution: AL = 01111000

2. LOOP
Instruction: LOOP Loop Instruction
Function: Shift bits left in a signed byte, word or
doubleword in a register or memory. Shift
all bits left, the bit that goes off is set
to CF.
Syntax: SAL memory, immediate
Sample Instruction: SHL AL, 1
Example before execution: AL = 01010101B
Example after execution: AL = 10101010B

3. LOOPE/ LOOPZ
Instruction: LOOPE/ LOOPZ Loop while equal/ Loop while
zero
Function: Shift bits right in an unsigned byte, word
or doubleword in a register or memory.
Shift all bits right, the bit goes off is
set to CF.
Syntax: SHR memory, immediate
Sample Instruction: SHR AL ,1
Example before execution: AL = 00101011
Example after execution: AL = 00010101

4. LOOPNE/ LOOPNZ
Instruction: LOOPNE/ LOOPNZ Loop while not equal/ Loop
while not zero
Function: Shift bits right in a signed byte, word or
doubleword in a register or memory. Shift
all bits right, the bit goes off is set to
CF.
Syntax: SAL memory, immediate
Sample Instruction: SAR AL, 1
Example before execution: AL = 10101010B
Example after execution: AL = 11010101
Computer Organization

And

Assembly Language

Anda mungkin juga menyukai