230 likes | 338 Views
CS 301 Fall 2002 Assembly Instructions. Slide Set 4. 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
E N D
CS 301 Fall 2002Assembly Instructions Slide Set 4
Symbolic Instructions 1Arithmetic • 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
Symbolic Instructions 2ASCII-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
Symbolic Instructions 3Bit 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
Symbolic Instructions 4Comparison • 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
Symbolic Instructions 5Data 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
Symbolic Instructions 6Flag 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
Symbolic Instructions 7Input/Output • IN: Input Byte or Word • OUT: Output Byte or Word • INSn: Input String • OUTSn: Output String
Symbolic Instructions 8Logical Operations • AND: Logical And • OR: Logical Or • NOT: Logical Not • XOR: Logical XOR
Symbolic Instructions 9Looping • LOOP: Loop Until Complete • LOOPE: Loop While Equal • LOOPZ: Loop While Zero • LOOPNE: Loop While Not Equal • LOOPNZ: Loop While Not Zero
Symbolic Instructions 10Stack 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
Symbolic Instructions 11String 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
Symbolic Instructions 12Transfer (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
Symbolic Instructions 13Transfer (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
Symbolic Instructions 14Transfer (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
Symbolic Instructions 15Transfer (Unconditional) • CALL: Call a Procedure • INT: Interrupt • IRET: Interrupt Return • JMP: Jump • RET: Return • RETN/RETF: Return Near/Far
Symbolic Instructions 16Type Conversion • CBW: Convert Byte To Word • CDQ: Convert Doubleword to Quadword • CWD: Convert Word to DoubleWord • CWDE: Convert Word to Extended DoubleWord
MOV – Move Data • Flags: Affects no flags • MOV reg/mem,reg/mem/imm
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
MUL - Multiply Unsigned Integers • Flags: Affects CF and OF. (AF,PF,SF, and ZF are undefined) • MUL reg/mem
DIV - Divide Unsigned IntegersIDIV – Divide Signed Integers • Flags: Affect AF,CF,OF,PF,SF, and ZF (all undefined) • DIV reg/mem • IDIV reg/mem
IMUL – Multiply Signed Integers • Flags: Affects CF and OF. (AF,PF,SF, and ZF are undefined)
Some Examples • Assembled ADD instructions • math.asm • prime.asm