In: Computer Science
Write an inline assembly program that initialized a 100 byte area of memory using the STOS instruction.
ASSEMBLY PROGRAM:---
MOV AL,0 ------>moves the value zero to AL register
LEA DI,BUFFER ------> loads effective address
MOV CX,100 ----->moves value 100 to CX register
CLD ----->clears direction flag
REP STOS BUFFER ------>repeats the above steps until count is zero
AL: Low byte of AX register
MOV: Command used to move data between registers and memory.
LEA: Load effective address.
DI : it is the destination index ,it is a pointer used to compare current character in string .
BUFFER : sequence of bytes.
CX : it is a 16 bit register.
CLD : It clears the direction flag. Direction flag is used to decide in which direction instructions work when used with REP command.
REP: This is similar to loops in java,but in this it is used to repeat all the instructions until count is 0.
STOS: it is used to store data(in bytes,word etc) from registers(AX,BX,CX) into specific memory locations(operands).The address is read from either ES:EDI or the ES:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively).