Lect 6: Instruction Set - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Lect 6: Instruction Set

Description:

RET. Intrasegment : RET within segment, RET within segment Adding Immediate to SP. Intersegment : RET, RET adding immediate to SP. Stack Frame Instructions: ENTER ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 7
Provided by: mae74
Category:
Tags: instruction | lect | ret | sal | set

less

Transcript and Presenter's Notes

Title: Lect 6: Instruction Set


1
Lect 6 Instruction Set
2
Instruction Set
  • Logic Instructions
  • AND, OR, XOR, NOT
  • Shift Instructions
  • SAL/SHL, SHR/SAR, SHLD, SHRD
  • SHL AX, 1 SAR AX, CL
  • Rotate Instructions
  • ROL, ROR, RCL, RCR
  • ROR AX,1 ROL AX, CL
  • Bit Test and Bit Scan Instructions
  • BT(Bit Test), BTR(Bit test and reset), BTS(Bit
    test and set), BTC(Bit test and complement),
    BSF(Bit scan forward), BSR(Bit scan reverse)
  • BT D, S CF BITD,S saves the value of the
    bit indicated by the first operand and the bit
    offset into the CF flag
  • BSF r16,r/m16 or BSF r32, r/m32
  • scans the bits in the second word or double
    word operand starting with bit 0. The ZF flag is
    set if all the bits are 0 otherwise, the ZF flag
    is cleared and the destination register is loaded
    with the bit index of the first set bit.

3
Instruction Set
  • Flag-Control Instructions
  • LAHF(Load AH from flags), SAHF(Store AH into
    flags), CLC, STC, CMC, CLI, STI
  • AH SFZF - AF - PF - CF
  • Compare and Set Instructions
  • CMP
  • SETcc r/m8 if condition then r/m8 1(not FF)
    else r/m8 0
  • SETA, SETAE,.....
  • Jump Instructions
  • Unconditional(JMP) and Conditional Jumps(JA, JAE,
    .... )
  • JMP Intrasegment jump, Intersegment jump
  • Intrasegment jump short(8-bit displacement
    -126 to 129), direct within segment (16-bit or
    32-bit relative), r/m indirect with segment
  • Intersegment jump direct intersegment (full
    offset and selector), indirect intersegment
  • Jcc conditional jump 8-bit or full
    displacement
  • JA, JAE, ....

4
Instruction Set
  • Subroutines and Subroutine-Handling Instructions
  • CALL and Return Instructions
  • CALL intrasegment and intersegment call
  • Intrasegment CALL rel16, or rel32, CALL
    indirect within segment
  • Intersegment CALL direct intersegment, CALL
    indirect intersegment
  • RET
  • Intrasegment RET within segment, RET within
    segment Adding Immediate to SP
  • Intersegment RET, RET adding immediate to SP
  • Stack Frame Instructions ENTER and LEAVE
  • to allocate and deallocate a data area called a
    stack frame
  • ENTER make a stack frame
  • ENTER imm16,0 Make procedure stack frame
  • ENTER imm16,1 Make stack frame for procedure
    parameter
  • ENTER imm16,imm8 Make stack frame for procedure
    parameter
  • first operand the number of bytes to be
    allocated on the stack for local data storage
  • second operand lexical nesting level of the
    routine

5
Instruction Set
Data for Proc. C (16 bytes) BP for Proc. C BP
for Proc. B BP for Proc. A BP for Proc. B Ret
addr for proc. B Data for Proc. B (12 bytes) BP
for Proc. B BP for Proc. A BP for Proc. A Ret
addr for proc. A Data for Proc. A (32 bytes) BP
for Proc. A Old BP
Stack frame for C
BP when executing Procedure C
Stack frame for B
BP when executing Procedure B
Stack frame for A
BP when executing Procedure A
6
Instruction Set
  • Loop and Loop-handling Instructions
  • LOOP, LOOPE/Z, LOOPNE/NZ CX must be preloaded
    with a count
  • String and String-Handling Instructions
  • MOVSB/W/D, compare string, scan string, load
    string, store string
  • the contents of both SI and DI are automatically
    incremented or decremented.
  • REP repeat string
  • Check Array Index Against Bounds
  • BOUND r16, m1616 check if r16 is within bounds
  • BOUND r32, m32m32 check if r32 is within bounds
  • operation if (LeftSRC lt RightSRC or LeftSRCgt
    RightSRCOperandSize/8)
  • then Interrupt 5
Write a Comment
User Comments (0)
About PowerShow.com