汇编语言有如下的汇编程序段,请完成code段中的代码,实现将string1段和string2段中的数据拷贝到string3段中,并且将string3段中的数据输出到屏幕。

2023-11-19

有如下的汇编程序段,请完成code段中的代码,实现将string1段和string2段中的数据拷贝到string3段中,并且将string3段中的数据输出到屏幕。

题目:
有如下的汇编程序段,请完成code段中的代码,实现将string1段和string2段中的数据拷贝到string3段中,并且将string3段中的数据输出到屏幕。

string1 segment

str1 db ‘welcome to $’

string1 ends

string2 segment

str2 db ‘quanzhou$’

string2 ends

string3 segment

str3 db 20 dup(0)

string3 ends

CODES SEGMENT

方案一:


CODES SEGMENT



START:

    mov ax,string1

    mov ds,ax         ;数据段设置为string1

    

    mov ax,string3

    mov es,ax         ;辅助段设置为string3

    

    mov bx,0

    mov cx,11

s:  mov al,[bx]

    mov es:[bx],al

    inc bx

    loop s            ;拷贝string1到string3

    

    mov ax,string2

    mov ds,ax         ;数据段改变为string2

    

    mov bx,0

    mov cx,8

s1: mov al,[bx]

    mov es:[bx+11],al

    inc bx

    loop s1           ;拷贝string2到string3



    mov bx,0

    mov cx,19

s2: mov dl,es:[bx]

    mov ah,02

    int 21h

    inc bx

    loop s2           ;将string3输出到屏幕

    

    MOV AH,4CH

    INT 21H

CODES ENDS

    END START

方案二:

CODES SEGMENT

start: mov ax,string1

   mov ds,ax

   mov ax,string3

   mov es,ax

   mov bx,0

   mov cx,11

s:mov ax,[bx]

   mov es:[bx],ax

   inc bx

   loop s

   mov ax,string2

   mov ds,ax

   mov bx,0

   mov cx,8

s1:mov ax,[bx]

   mov es:[bx+11],ax

   inc bx

   loop s1

   mov bx,0

   mov cx,19

   mov dx,offset string3

   mov ah,09

   int 21h

   mov ax,004ch

   int 21h

CODES ends

end start
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

汇编语言有如下的汇编程序段,请完成code段中的代码,实现将string1段和string2段中的数据拷贝到string3段中,并且将string3段中的数据输出到屏幕。 的相关文章

随机推荐