
PROGRAMMING CONCEPTS–III 4-7
Example 4.4
.MODEL SMALL ;select small model
.DATA ;start data segment
AREA DW 50 DUP(?) ;define AREA
.CODE ;start code segment
.STARTUP ;start program
MOV AX, DS ;copy DS to AX
MOV ES, AX ;copy AX to ES
LEA DI, AREA ;address AREA with DI
MOV CX, 50 ;load count in CX
CLD ;clear direction flag
MOV AX, 0001 ;load AX with 0
REP STOSW ;repeat until CX = 0
.EXIT ;exit to DOS
END ;end of program
It is obvious that the STOS instruction is used to fill up an area in memory with the same
data.
ii) LODS
The last of the string instructions is LODS. This is an instruction for ‘loading’. Loading
always means ...