Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 在MASM中连接字符串_Assembly_Masm_Irvine32 - Fatal编程技术网

Assembly 在MASM中连接字符串

Assembly 在MASM中连接字符串,assembly,masm,irvine32,Assembly,Masm,Irvine32,我一直在尝试在MASM中连接字符串,但遇到了一些困难。首先,此时我的输出是一个带有树型字符的0,但我认为可能我的WriteString(来自Irvine库)没有被正确使用。WriteString是否从edx或eax写入? 我还知道,当使用字符串时,我需要使用指向其第一个字符的地址的指针,而不是整个字符串;这就是我试图对缓冲区和偏移指针所做的,但我不确定这是否完全正确。我也不确定推送和弹出是否有必要,如果有必要,具体是做什么的。 请帮忙!非常感谢 以下是我编写的代码: TITLE Str_Conc

我一直在尝试在MASM中连接字符串,但遇到了一些困难。首先,此时我的输出是一个带有树型字符的0,但我认为可能我的
WriteString
(来自Irvine库)没有被正确使用。
WriteString
是否从
edx
eax
写入? 我还知道,当使用字符串时,我需要使用指向其第一个字符的地址的指针,而不是整个字符串;这就是我试图对缓冲区和偏移指针所做的,但我不确定这是否完全正确。我也不确定推送和弹出是否有必要,如果有必要,具体是做什么的。 请帮忙!非常感谢

以下是我编写的代码:

TITLE Str_Concat        (WA5.asm)

; Program Description: This program concatenates a source string to a target string.
; Author: 
; Date Created: 2/6/2013


INCLUDE C:\IrvineExamplesVS2010a\Irvine32.inc

.data
    source BYTE "Rocks",0
    target BYTE "Zachary",0
    buffer BYTE 24 DUP (0)

.code
main PROC
    push ds    
    pop es

    mov esi, OFFSET source
    mov edi, OFFSET target
    cld                         ;direction = forward
    mov cx, LENGTHOF source
    rep movsb

    call WriteString
    call crlf


        exit        ; exit to operating system
main ENDP

END main

欧文在书中解释了他的大部分程序。他的图书馆的来源也可以从他的网站上下载。在源代码中,他留下了一些关于进程的参数、寄存器以及每个进程返回的信息。以下是
WriteString
中的描述:

WriteString PROC
;
; Writes a null-terminated string to standard
; output. Input parameter: EDX points to the
; string.
; Last update: 9/7/01
;--------------------------------------------------------
那么,在读了这些之后,您会将
目标的地址放在哪个寄存器中?您不能按原样使用
edi
,因为
edi
中的原始地址已由
rep movsb

另一方面,您并没有连接字符串,而是用
中的字符串覆盖
目标
中的字符串。您定义了
缓冲区,但从未使用过它<代码>缓冲区
是否将两个字符串保持在一起?如果是这样,您需要将
目标
复制到
缓冲区
中,然后将
复制到
缓冲区