首页 > 代码库 > 汇编-串操作-字符串拷贝

汇编-串操作-字符串拷贝



一、实习题目:串操作


二、实习目的:掌握串操作程序设计的基本方针


三、实习内容:将首地址DATA1按字节存储的数据块通过使用字符串操作将其移动到首地址为

                          DATA2数据块中。


四、代码:

<strong> </strong>data segment 

  dataOne    db 'It is a temp string',0ah,0dh,'$'
  dataTwo    db 50 dup(?)
  
  msgOne     db 0ah,0dh,'source string:','$'
  msgTwo     db 0ah,0dh,'distance string:','$'
  
data ends

code segment

  assume DS:data,CS:code
start:
  mov ax,data;
  mov DS,ax;
  
  lea si,dataOne;
  
  
  mov ax,seg dataTwo;
  mov ES,ax;
  lea di,dataTwo;
  
  
  mov cx,22;
again:
  movsb;
  loop again;
  
  lea dx,msgOne;
  mov ah,09h;
  int 21h;
  
  lea dx,dataOne;
  mov ah,09h;
  int 21h
  
  lea dx,msgTwo;
  mov ah,09h;
  int 21h;
  
  lea dx,dataTwo;
  mov ah,09h;
  int 21h;

  mov ah,4ch;
  int 21h;

code ends
end start


五、运行结果:


汇编-串操作-字符串拷贝