在汇编中操作字符串(MASM) [英] Manipulating Strings in Assembly (MASM)
问题描述
.data
source BYTE "Defense mechanism",0
target BYTE SIZEOF source DUP(0)
.code
main PROC
mov esi, OFFSET target
mov edi, OFFSET target
mov ecx, SIZEOF source
L1:
mov al,[esi] ; get a character from source
mov [edi],al ; store it in the target
inc esi ; move to next character
inc edi
loop L1
在 .data
部分中,我看到 source
被定义为字符串.在 .code
部分中,我看到 target
的内存位置存储在源索引中.我是否不应该希望源索引( ESI
)指向 source
而不是 target
?该程序应该将一个字符串复制到已初始化为源字符串大小的目标框中,并用零填充每个字段.我没有汇编语言的经验.我怎么了?(注意:这是我的教授列出程序的方式,但是他没有提供任何实际资料,因为这是基于Web的计算安全性"课程.
In the .data
section, I see that source
is defined as the string.
In the .code
section, I see that the memory location of target
is stored in the source index. Shouldn't I want the source index (ESI
) to point to source
instead of target
? This program is supposed to copy a string into the target box that has been initialized to the size of the source string and to have each of the fields filled with zeroes. I have no experience with Assembly language. What am I getting wrong? (Note: this is how my professor has the program listed out, but he isn't offering any real material on this because this is a web based "security in computing" course.
推荐答案
是的,您是对的- esi
应该指向 source
,而不是 target
-看来您的教授在该代码中至少有一个错误.更改:
Yes, you're right - esi
should point at source
, not target
- it looks like your professor has at least one bug in that code. Change:
mov esi, OFFSET target
收件人:
mov esi, OFFSET source
这篇关于在汇编中操作字符串(MASM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!