【问题标题】:how can l changed this solution?我怎么能改变这个解决方案?
【发布时间】:2016-04-12 01:02:33
【问题描述】:
org 100h

jmp var1       ; jump over data declaration

source db 'This is the source string',0
target db SIZEOF source DUP ('#')


var1:
Mov   SI,25;lenght of the string
start:  

Mov  AL,source[SI]
DEC SI    

Mov  ah ,0eh
int 10h   
mov BL,target[DI]

CMP source[SI],BL;comparing to get the end of the string
je stop

jmp start                     

stop:
mov     ah, 0 
      ; wait for any key....
ret ; return to operating system. 

【问题讨论】:

  • 欢迎来到 StackOverflow,感谢您发布您的第一个问题。为了获得最佳答案,问题应该清楚您正在努力实现的目标以及您为达到现在的位置所做的工作。有一个great article about how to write good questions,请考虑阅读并编辑您的问题,以便更清楚地了解您想要什么。
  • 我不想在程序中微笑或其他符号
  • 魔术八球告诉我,您正试图弄清楚为什么您的代码在字符串结束后继续写入。
  • ..... 21h ;等待任何键.... ret ;返回操作系统。

标签: string assembly x86 reverse


【解决方案1】:

让我们一块一块地来...

我们有了一个好的开始:

org 100h

jmp var1       ; jump over data declaration

source db 'This is the source string',0
target db SIZEOF source DUP ('#')


var1:
Mov   SI,25;lenght of the string
start:  

Mov  AL,source[SI]
DEC SI    

Mov  ah ,0eh
int 10h   
mov BL,target[DI]

这里我们发现了我们的第一个问题。您永远不会将 DI 设置为任何值。 DI 绝对可以有任何价值。既然这是再熟悉不过的“在汇编中反转字符串”的赋值,我就不给你解决了。

CMP source[SI],BL;comparing to get the end of the string

如何检查字符串的结尾?你的主要问题就在这里。您将 source[26] (左右)设置为零。您不应该检查source[SI] 是否等于零吗?

je stop

jmp start                     

所以,请将此答案作为调试的免费赠品。但是,我仍然投票决定将其作为副本关闭! :)

【讨论】:

    猜你喜欢
    • 2011-04-29
    • 1970-01-01
    • 2023-04-03
    • 2022-06-15
    • 2021-05-20
    • 1970-01-01
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    相关资源
    最近更新 更多