CS 301 Fall 2001 - PowerPoint PPT Presentation

About This Presentation
Title:

CS 301 Fall 2001

Description:

ASCII-BCD conversion. AAA: ASCII Adjust After Addition. AAS: ASCII Adjust After Subtraction. AAM: ASCII Adjust After Multiplication. AAD: ASCII Adjust Before Division ... – PowerPoint PPT presentation

Number of Views:405
Avg rating:3.0/5.0
Slides: 24
Provided by: chrish66
Learn more at: https://www.cs.uaf.edu
Category:
Tags: adjust | after | ascii | fall

less

Transcript and Presenter's Notes

Title: CS 301 Fall 2001


1
CS 301 Fall 2001 Chapter 6
  • Slides by Prof. Hartman, following IBM PC
    Assembly Language Programming by Peter Abel

2
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

3
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

4
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

5
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

6
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

7
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

8
Symbolic Instructions 7Input/Output
  • IN Input Byte or Word
  • OUT Output Byte or Word
  • INSn Input String
  • OUTSn Output String

9
Symbolic Instructions 8Logical Operations
  • AND Logical And
  • OR Logical Or
  • NOT Logical Not
  • XOR Logical XOR

10
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

11
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

12
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

13
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

14
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

15
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

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

17
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

18
MOV Move Data
  • Flags Affects no flags
  • MOV reg/mem,reg/mem/imm

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

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 DXAX AX 16-bit operand
32-bit EDXEAX EAX 32-bit operand
21
DIV - Divide Unsigned IntegersIDIV 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 (DXAX)/operand AX DX
32-bit (EDXEAX)/operand EAX EDX
22
IMUL Multiply Signed Integers
  • Flags Affects CF and OF. (AF,PF,SF, and ZF are
    undefined)

Format Format Format Format Effect
dest source1 source2 Effect
IMUL reg/mem8 AX AL source1
IMUL reg/mem16 DXAX AX source1
IMUL reg/mem32 EDXEAX EAX source1
IMUL reg reg/mem/imm dest source1
IMUL reg reg/mem imm dest source1 source2
23
Some Examples
  • Assembled ADD instructions
  • math.asm
  • prime.asm
Write a Comment
User Comments (0)
About PowerShow.com