; CS2011, A Term 1999
; Prof. Sergio A. Alvarez

title Indexed Addressing Example
; this program accepts an input string in memory
; and copies it to a different location in memory
; indexed addressing is used to scan the strings

.model small
.stack

.data
; hey, what's the following string supposed to say, anyway?
string1 db "J^h[[Y^[[hi\eh_dZ[n[ZWZZh[ii_d" ; stored as ASCII codes
numbytes = $-string1 ; length of string1 as offset difference
string2 db 80 dup(?) ; uninitialized bytes for future use

.code
.startup
   mov di,0 ; start at offset 0 relative to beginning of string1
   mov cx,numbytes
   copyloop:
      mov bh,string1[di]  ; get current character (ASCII code)
      mov string2[di],bh  ; copy to appropriate position in string2
      inc di              ; point to next character
   loop copyloop
.exit

end


