CISC versus RISC - PowerPoint PPT Presentation

About This Presentation
Title:

CISC versus RISC

Description:

The x86's string-manipulation' instructions are examples of the ... manner (e.g., copying, comparing, and searching long strings of characters stored in memory) ... – PowerPoint PPT presentation

Number of Views:116
Avg rating:3.0/5.0
Slides: 10
Provided by: CRU7
Learn more at: https://www.cs.usfca.edu
Category:
Tags: cisc | risc | strings | versus

less

Transcript and Presenter's Notes

Title: CISC versus RISC


1
CISC versus RISC
  • Two competing philosophies for the design of a
    processors instruction-set

2
The RISC idea
  • RISC Reduced Instruction-Set Computer
  • There will be a relatively small number of very
    simple operations that the CPU can execute, which
    the programmer uses as basic building blocks for
    constructing complex algorithms
  • Because there are so few instructions, they can
    be uniquely identified by only a few bits
  • Hence these short instructions can be more
    quickly fetched, decoded, and executed

3
The CISC idea
  • CISC Complex Instruction-Set Computer
  • Identify the most important operations that a
    computer will need to perform, then build the
    circuitry for each one of those operations into
    its own special-purpose machine-instruction
  • Instead of fetching a large number of small
    instructions, it will be more efficient to fetch
    and execute just one very powerful instruction

4
Some x86 CISC instructions
  • The x86s string-manipulation instructions are
    examples of the CISC philosophy
  • These instructions are specially designed to do
    the most common word processing operations in
    an optimized manner (e.g., copying, comparing,
    and searching long strings of characters stored
    in memory)

5
The string operations
  • Move-string movs
  • Compare-strings cmps
  • Scan-string scas
  • Store-string stos
  • Load-string lods
  • Output-string outs
  • Input-string ins

6
Initial setup
  • Each of the string-instructions requires a
    certain amount of preparatory setup, but then can
    repeatedly execute an operation without needing
    to re-fetch and re-decode
  • Hence the overall string-operation can be done
    more efficiently than could be done by using a
    customary program-loop

7
Example strlen
Finding the length of a null-terminated
string of ASCII character-codes mov msg,
rdi point RDI to beginning of the
string mov 0, al setup the null-bytes
value in AL cld clear the DF-bit in EFLAGS
mov -1, rcx maximum unsigned integer in
RCX repne scasb scan string for its first
NULL byte sub msg, rdi subtract start to
get string length
8
Midterm question
  • On a different topic, we show a slide which
    conveys an idea for solving Question V
  • Most of the code in our myargs.s demo can be
    reused, but a couple of changes will be needed
  • Start from the end of the array of pointers,
    instead of from the beginning
  • Decrement the array-index upon each pass through
    the loop, instead of incrementing it

9
reorder.s
command-line
./reorder xx yyy zzzz
0 8 16
24 32 40
argc (4)
argv0
argv1
argv2
argv3
NULL (0)
RSP
.
/
r
e
o
r
d
e
r
x
x
y
y
y
z
z
z
z
argc (argument count) number of strings
typed on the command-line
mov (rsp), rbx dec rbx mov 8( rsp,
rbx, 8 ), rsi
? RSI (argv3)
Write a Comment
User Comments (0)
About PowerShow.com