Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 301 Fall 2002 Assembly Instructions

Similar presentations


Presentation on theme: "CS 301 Fall 2002 Assembly Instructions"— Presentation transcript:

1 CS 301 Fall 2002 Assembly Instructions
Slide Set 4 9/20/2018

2 Symbolic Instructions 1 Arithmetic
ADD: Add ADC: Add with carry SUB: Subtract SBB: Subtract with borrow NEG: Negate XADD: Exchange and add INC: Increment by 1 DEC: Decrement by 1 MUL: Unsigned multiply DIV: Unsigned divide IMUL: Signed multiply IDIV: Signed divide 9/20/2018

3 Symbolic Instructions 2 ASCII-BCD conversion
AAA: ASCII Adjust After Addition AAS: ASCII Adjust After Subtraction AAM: ASCII Adjust After Multiplication AAD: ASCII Adjust Before Division DAA: Decimal Adjust After Addition DAS: Decimal Adjust After Subtraction 9/20/2018

4 Symbolic Instructions 3 Bit Shifting
RCL: Rotate Left Through Carry RCR: Rotate Right Through Carry ROL: Rotate Left ROR: Rotate Right SAL: Shift Algebraic Left (=SHL) SAR: Shift Algebraic Right SHL: Shift Logical Left (=SAL) SHR: Shift Logical Right SHLD: Shift Left Double SHRD: Shift Right Double 9/20/2018

5 Symbolic Instructions 4 Comparison
BSF/BSR: Bit Scan BT/BTC/BTR/BTS: Bit Test CMP: Compare CMPSn: Compare String CMPXCHG: Compare and Exchange CMPXCHG8B: Compare and Exchange TEST: Test bits 9/20/2018

6 Symbolic Instructions 5 Data Transfer
LDS: Load DS register LEA: Load Effective Address LnS: Load nS register LODS: Load String MOV: Move Data MOVSn: Move String MOVSX: Move with Sign-Extend MOVZX: Move with Zero-Extend STOS: Store String XCHG: Exchange XLAT: Translate 9/20/2018

7 Symbolic Instructions 6 Flag Operations
CLC/STC: Clear/Set CF CLD/STD: Clear/Set DF CLI/STI: Clear/Set IF CMC: Complement CF LAHF: Load AH from Flags SAHF: Store AH in Flags POPF: Pop Flags Off Stack PUSH: Push Flags On Stack 9/20/2018

8 Symbolic Instructions 7 Input/Output
IN: Input Byte or Word OUT: Output Byte or Word INSn: Input String OUTSn: Output String 9/20/2018

9 Symbolic Instructions 8 Logical Operations
AND: Logical And OR: Logical Or NOT: Logical Not XOR: Logical XOR 9/20/2018

10 Symbolic Instructions 9 Looping
LOOP: Loop Until Complete LOOPE: Loop While Equal LOOPZ: Loop While Zero LOOPNE: Loop While Not Equal LOOPNZ: Loop While Not Zero 9/20/2018

11 Symbolic Instructions 10 Stack Operations
ENTER: Make Stack Frame LEAVE: Terminate Stack Frame POP: Pop Word Off Stack PUSH: Push Word On Stack POPF: Pop Flags Off Stack PUSHF: Push Flags On Stack POPA: Pop All General Registers PUSHA: Push All General Registers 9/20/2018

12 Symbolic Instructions 11 String Operators
CMPS: Compare String LODS: Load String MOVS: Move String REP: Repeat String REPE: Repeat While Equal REPZ: Repeat While Zero REPNE: Repeat While Not Equal REPNZ: Repeat While Not Zero SCAS: Scan String STOS: Store String 9/20/2018

13 Symbolic Instructions 12 Transfer (Conditional) 1
INTO: Interrupt On Overflow JA: Jump if Above JAE: Jump if Above/Equal JB: Jump if Below JBE: Jump if Below/Equal JC: Jump if Carry JCXZ: Jump if CX is Zero JE: Jump if Equal JG: Jump if Greater JGE: Jump if Greater/Equal JL: Jump if Less 9/20/2018

14 Symbolic Instructions 13 Transfer (Conditional) 2
JLE: Jump if Less/Equal JNA: Jump if Not Above JNAE: Jump if Not Above/Equal JNB: Jump if Not Below JNBE: Jump if Not Below/Equal JNC: Jump if No Carry JNE: Jump if Not Equal JNG: Jump if Not Greater JNGE: Jump if Not Greater/Equal JNL: Jump if Not Less 9/20/2018

15 Symbolic Instructions 14 Transfer (Conditional) 3
JNLE: Jump if Not Less/Equal JNO: Jump if No Overflow JNP: Jump if No Parity JNS: Jump if No Sign JNZ: Jump if Not Zero JO: Jump if Overflow JP: Jump if Parity JPE: Jump if Parity Is Even JPO: Jump if Parity Is Odd JS: Jump if Sign JZ: Jump if Zero 9/20/2018

16 Symbolic Instructions 15 Transfer (Unconditional)
CALL: Call a Procedure INT: Interrupt IRET: Interrupt Return JMP: Jump RET: Return RETN/RETF: Return Near/Far 9/20/2018

17 Symbolic Instructions 16 Type Conversion
CBW: Convert Byte To Word CDQ: Convert Doubleword to Quadword CWD: Convert Word to DoubleWord CWDE: Convert Word to Extended DoubleWord 9/20/2018

18 MOV – Move Data Flags: Affects no flags MOV reg/mem,reg/mem/imm
9/20/2018

19 ADD (and ADC/SUB/SBB) Add, Add with Carry, Subtract, Subtract with borrow. Flags: All affect AF,CF,OF,PF,SF, and ZF ADD reg/mem, reg/mem/imm ADC reg/mem, reg/mem/imm SBB reg/mem, reg/mem/imm SUB reg/mem, reg/mem/imm 9/20/2018

20 MUL - Multiply Unsigned Integers
Flags: Affects CF and OF. (AF,PF,SF, and ZF are undefined) MUL reg/mem Size of operand Effect 8-bit AX = AL * 8-bit operand 16-bit DX:AX = AX * 16-bit operand 32-bit EDX:EAX = EAX * 32-bit operand 9/20/2018

21 DIV - Divide Unsigned Integers IDIV – Divide Signed Integers
Flags: Affect AF,CF,OF,PF,SF, and ZF (all undefined) DIV reg/mem IDIV reg/mem Size of operand Operation Quotient Remainder 8-bit AX/operand AL AH 16-bit (DX:AX)/operand AX DX 32-bit (EDX:EAX)/operand EAX EDX 9/20/2018

22 IMUL – Multiply Signed Integers
Flags: Affects CF and OF. (AF,PF,SF, and ZF are undefined) Format Effect dest source1 source2 IMUL reg/mem8 AX = AL * source1 reg/mem16 DX:AX = AX * source1 reg/mem32 EDX:EAX = EAX * source1 reg reg/mem/imm dest *= source1 reg/mem imm dest = source1 * source2 9/20/2018

23 Some Examples Assembled ADD instructions math.asm prime.asm 9/20/2018


Download ppt "CS 301 Fall 2002 Assembly Instructions"

Similar presentations


Ads by Google