LODSB loads the byte at DS:SI into AL and moves SI to the next byte: +1 when DF = 0, -1 when DF = 1. LODSW loads AX and steps by 2. No flags change, so it can sit between a compare and its jump. It is a one-byte replacement for MOV AL, [SI] / INC SI.

The source segment can be overridden (LODS BYTE PTR ES:[SI]), since the source of every string instruction is DS:SI by default. DI is not involved.

With STOS: process a string

LODS is almost never repeated: REP LODSB is legal but each load overwrites the last, leaving only the final element in AL. Its real use is in a loop, often paired with STOSB: load an element, change it in AL, store it at ES:DI. When SI and DI start at the same address the string is changed in place. The loop below turns a string into capitals.

CLD
MOV SI, OFFSET TXT1
MOV DI, SI ; write back in place
MOV CX, 5
NEXT1:
LODSB ; AL = [SI], SI + 1
CMP AL, 'a'
JB KEEP1
CMP AL, 'z'
JA KEEP1
SUB AL, 20h ; lowercase to uppercase
KEEP1:
STOSB ; [DI] = AL, DI + 1
LOOP NEXT1
MOV DX, OFFSET TXT1
MOV AH, 09h ; DOS: print the string at DS:DX
INT 21h
TXT1 DB 'shout', 13, 10, '$'

A loop can also stop on content instead of a count: load, CMP AL, 0, JE out. LODSW reads two bytes at a time; the byte at the lower address lands in AL. With a table of words, LODSW walks it one entry per instruction.

Pitfalls: forgetting CLD; and expecting SI to still point at the element you just loaded. After LODSB going forward it is at SI - 1.