Laboratory 6 - Theory

Instructions working on strings of bytes/words/doublewords

String operations

  • Instructions working on strings have default operands (parameters).
Types of string instructions:
  • which use a source string and a destination string (MOVSB, MOVSW, MOVSD, CMPSB, CMPSW, CMPSD)
  • which use only a source string (LODSB, LODSW, LODSD)
  • which use only a destination string (STOSB, STOSW, STOSD, SCASB, SCASW, SCASD)
You will remember them more easily:)
  • Move String = MOVS
  • Compare String = CMPS
  • Load String = LODS
  • Store String = STOS
  • Scan String = SCAS
A string is characterized by:
  • the type of the elements(bytes or words) => is given by the last letter of the instruction that is used (B=byte, W=word, D=doubleword), both strings having the same type
  • the address of the first element => is a FAR memory address which is memorised in:
    • in DS:ESI - for the source string
    • in ES:EDI - for the destination string
  • the parsing direction => is given by the value of the DF flag (0 - from small addresses to large addresses, 1 - from large addresses to small addresses.)
  • the number of elements => when needed is placed in CX or ECX