; rep_movsb.asm
; REP and MOVSB demo program
.586P
; Flat memory model
.MODEL FLAT, STDCALL
;---------------------------------------
; Data segment
_DATA SEGMENT
mystring BYTE "abc"
otherstr BYTE 10 DUP(?)
MYSTRING_SIZE EQU 3 ; mystring is 3 bytes long
_DATA ENDS
;---------------------------------------
; Code segment
_TEXT SEGMENT
START:
mov esi, OFFSET mystring ; source offset
mov edi, OFFSET otherstr ; destination offset
mov ecx, MYSTRING_SIZE ; set number of bytes to copy
cld ; clear DF (destination pointers will be increased)
rep movsb ; repeat until ECX is zero:
; copy mystring to otherstr
ret ; Exit
_TEXT ENDS
END START