Intel - PowerPoint PPT Presentation

About This Presentation
Title:

Intel

Description:

Unconditional Jumps: jmp' and ljmp' Subroutine Calls: call' and lcall' ... Conditional Jumps: jz', jnz', jc', jnc', etc. These transfers do not modify the FLAGS ... – PowerPoint PPT presentation

Number of Views:121
Avg rating:3.0/5.0
Slides: 20
Provided by: cru6
Learn more at: https://www.cs.usfca.edu
Category:
Tags: intel | jumps

less

Transcript and Presenter's Notes

Title: Intel


1
Intels 8086 instruction-set
  • A look at the main categories of processor
    instructions for the earliest Intel x86 CPU

2
Data-Transfer
  • These instructions simply copy some data from one
    place in the system to another
  • From one register to another register
  • From a memory location to a register
  • From a register to a memory location
  • From within an instruction to a register
  • From within an instruction to a memory cell

3
mov
  • Its the most frequently-used instruction

immediate data
general register
general register or memory
segment register
4
Some other data-transfers
  • Exchange (xchg)
  • Push/Pop
  • Pushf/Popf
  • In/Out
  • Load pointer (lds, les, lfs, lgs, lss)
  • Note A distinctive feature data-transfers is
    that FLAGS are unmodified (except popf)

5
Arithmetic Instructions
  • Addition add and adc
  • Subtraction sub and sbb
  • Multiplication mul and imul
  • Division div and idiv
  • Increment/Decrement inc and dec
  • Comparison/Negation cmp and neg
  • All these instructions do modify FLAGS

6
Boolean Logic Instructions
  • Bitwise AND and
  • Bitwise OR or
  • Bitwise XOR xor
  • Bitwise TEST test
  • Bitwise complement not
  • These instructions also modify FLAGS

7
Shift/Rotate Instructions
  • Left-shifts shl and sal
  • Right-shifts shr and sar
  • Left-rotations rol and rcl
  • Right-rotations ror and rcr
  • These instructions affect the Carry-Flag

8
Control Transfers
  • These instructions modify register RIP so as to
    alter the normal fetch-execute cycle
  • Unconditional Jumps jmp and ljmp
  • Subroutine Calls call and lcall
  • Subroutine Returns ret and lret
  • Conditional Jumps jz, jnz, jc, jnc, etc
  • These transfers do not modify the FLAGS

9
String Manipulations
  • This unusual group of complex instructions is for
    efficient word-processing operations
  • Move string movs
  • Compare string cmps
  • Scan string scas
  • Store string stos
  • Load string lods
  • Repeat prefixes rep, repe and repne

10
Processor Control
  • This group of instructions is for specialized
    systems programming situations
  • Halt the fetch-ececute cycle hlt
  • Wait for coprocessor to finish wait
  • Lock the system bus temporarily lock
  • Adjust the Direction Flag cld or std
  • Adjust the Interrupt Flag cli or sti
  • Adjust the Carry Flag cmc, clc or stc

11
Special-purpose instruction
initializations
the loop body
This two-step construct occurs so often within
ordinary programs that a special instruction
is available to do both in a single
instruction
decrement RCX
RCX 0?
no
yes
12
Stack operation push
register
data
64-bits
64-bits
data
data
data
data
data
data
SSRSP
data
unused
SSRSP
unused
unused
unused
unused
before push
after push
The push instruction, applied to a register,
performs a two-step operation first, the value
in the stack-pointer register is decreased by 8,
and then the value in the register operand is
copied into the stack-location at SSRSP
13
Stack operation pop
register
64-bits
64-bits
data
data
data
data
data
data
SSRSP
unused
data
SSRSP
unused
unused
unused
unused
before pop
after pop
The pop instruction, applied to a register,
performs a two-step operation first, the value
in the stack-location at SSRSP is copied into
that register, and afterward the value in the
stack-pointer register is increased by 8.
14
An application
  • We can apply these stack-operations to a string
    of characters in a memory-buffer, so as to
    reverse the order of those characters

stack
A B C D
RSP
buffer
buffer
A B C D
D C B A
pop
pop
pop
pop
push
push
push
push
15
reverse.s
  • Weve constructed a demo-program that reverses
    the order of characters which a user types in
  • It uses the push and pop operations, as well
    as the special x86 loop instruction
  • It also employs the read system-call to get a
    string of characters typed by a user

16
The programs flow
Prompt the user for input
INPUT
Accept the users response
Loop to push each buffer character onto stack
PROCESS
Loop to pop each character to output buffer
Show rearranged characters in output buffer
OUTPUT
17
Loops are consecutive
18
Loops are nested
19
In-class exercise
  • Can you modify the reverse.s program so all
    words remain in the same order, but the order of
    the letters within each word do get reversed?
  • HINT You will need a loop-within-a-loop

This is our moment, this is our time.
INPUT
sihT si rou themom, siht si rou emit.
OUTPUT
Write a Comment
User Comments (0)
About PowerShow.com