Home  Site Map  Instruction Index 

LODSB and LODSW  -  Load Instruction


The LODSB and LODSW instructions are used to read data into AX from the address pointed to by the SI register. After each call the SI register is incremented by one byte for LODSB or by two bytes for LODSW.
This command has 1 part, the Instruction.

SI is decremented backwards when the direction flag is set using the STD instruction.

LODSB reads one byte to AL, LODSW reads 2 bytes to AX.
Unlike MOVSB and MOVSW it can only be used to move data in the same sement.

These commands are limited to the current DS code segment.

This example reads 16 single bytes before exiting the LOOP.



Assembly
Sample
Description   16 bit Machine
  Code
MOV CX, 0x0010;  Assign 10h (16) to the Counter CX   B9 10 00
MOV SI, DataString;  Assign SI to point at a memory
;  location to be read.
  BE 26 01
LODSB;  Load one byte into AL   AC
LOOP 0xFDLOOP back to LODSB to read
;  each byte until CX = 0
  E2 FD