StringInstructions - The String Instructions The String...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
The String Instructions Beta Draft - Do not distribute © 2001, By Randall Hyde Page 935 The String Instructions Chapter Six 6.1 Chapter Overview A string is a collection of objects stored in contiguous memory locations. Strings are usually arrays of bytes, w ords, or (on 80386 and later processors) double w ords. The 80x86 microprocessor f amily supports se v eral instructions specifi cally designed to cope with strings. This chapter e xplores some of the uses of these string instructions. The 80x86 CPUs can process three types of strings: byte strings , w ord strings , and double w ord strings . The y can mo v e strings , compare strings , search for a specifi c v alue within a string , initialize a string to a fi x ed v alue , and do other primiti v e operations on strings. The 80x86’ s string instructions are also useful for manipulating arrays, tables, and records. Y ou can easily assign or compare such data structures using the string instructions. Using string instructions may speed up your array manipulation code considerably . 6.2 The 80x86 String Instructions All members of the 80x86 f amily support fi v e dif ferent string instructions: MO VS x , CMPS x , SCAS x , LODS x , and ST OS x 1 . ( x = B, W , or D for byte, w ord, or double w ord, respecti v ely . This te xt will generally drop the x suf fi x when talking about these string instructions in a general sense.) The y are the string primi - ti v es since you can b uild most other string operations from these fi v e instructions. Ho w you use these fi v e instructions is the topic of the ne xt se v eral sections. For MOVS: movsb(); movsw(); movsd(); For CMPS: cmpsb(); // Note: repz is a synonym for repe cmpsw(); cmpsd(); // Note: repnz is a synonym for repne. For SCAS: scasb(); scasw(); scasd(); For STOS: stosb(); stosw(); stosd(); 1. The 80x86 processor support two additional string instructions, INS and OUTS which input strings of data from an input port or output strings of data to an output port. We will not consider these instructions since they are privileged instructions and you cannot execute them in a standard 32-bit OS application.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter Six Volume Six Page 936 © 2001, By Randall Hyde Beta Draft - Do not distribute For LODS: lodsb(); lodsw(); lodsd(); 6.2.1 How the String Instructions Operate The string instructions operate on blocks (contiguous linear arrays) of memory . F or e xample, the MO VS instruction mo v es a sequence of bytes from one memory location to another . The CMPS instruction com - pares tw o blocks of memory . The SCAS instruction scans a block of memory for a particular v alue. These string instructions often require three operands, a destination block address, a source block address, and (optionally) an element count. F or e xample, when using the MO VS instruction to cop y a string, you need a source address, a destination address, and a count (the number of string elements to mo v e).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/08/2011 for the course CS 101 taught by Professor Jitenderkumarchhabra during the Summer '11 term at National Institute of Technology, Calicut.

Page1 / 14

StringInstructions - The String Instructions The String...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online