汇编——两个字符串拼接

; multi-segment executable file template.

data segment
    ; add your data here!  
    string1 db 'abcdefg'  
    string2 db 'zzzzzzz'
    string3 db 'hijklmn'
    string4 db   ''
    
    ;pkey db "press any key...$"
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax 
    mov es,ax
    lea si,string1
    lea di,string4
    mov cx,7
    cld                  ;使df=0,实现地址自动增量
    rep movsb          ; movs es:[di],ds:[si]  
    lea si,string3
    mov cx,7
    cld
    rep movsb

    ; add your code here
            
   ; lea dx, pkey
    mov ah, 9
    int 21h        ; output string at ds:dx
    
    ; wait for any key....    
    mov ah, 1
    int 21h
    
    mov ax, 4c00h ; exit to operating system.
    int 21h    
ends

end start ; set entry point and stop the assembler.

 

你可能感兴趣的:(汇编语言)