【问题标题】:Copy two string on assembly在程序集上复制两个字符串
【发布时间】:2012-06-12 15:58:00
【问题描述】:

这是复制 2 个字符串的代码

TITLE Copying a String (CopyStr.asm)
INCLUDE Irvine32.inc
.data
source BYTE "This is the source string",0
target BYTE SIZEOF source DUP(0)
.code
main PROC
mov esi,0 ; index register
mov ecx,SIZEOF source ; loop counter
L1:
mov al,source[esi] ; get a character from source
mov target[esi],al ; store it in the target
inc esi ; move to next character
loop L1 ; repeat for entire string
exit
main ENDP
END main

mov esi,0 ;索引寄存器

为什么它假定索引将从 0 开始它是如何知道 SOURCE 的索引是 0 我觉得应该是

mov esi , offset Source

???

【问题讨论】:

  • 代码完全转储,应该使用rep movsb...

标签: string assembly copy masm irvine32


【解决方案1】:

看看

mov al,source[esi] ; get a character from source

esi 是“Extended Source Index”寄存器,它将偏移存储在源(字符串)中(更多关于 ESI/EDI 寄存器here)。

【讨论】:

    【解决方案2】:

    source.data部分,这个符号是字符串的起始地址。 esi 寄存器存储从source 地址开始的字节偏移量。 eax 寄存器的下部接收内存在source 基地址加上esi 内的偏移量(0, 1, 2, 3, ...随着循环的进行)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-17
      • 2017-11-19
      • 2013-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多