2016-04-12 39 views
-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] 

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. 

enter image description here我该如何更改此解决方案?

+2

欢迎来到StackOverflow,感谢您发布您的第一个问题。为了获得最好的答案,问题应该清楚说明你想要达到的目标以及你已经完成的目标。有一篇关于如何编写好问题的伟大文章(http://stackoverflow.com/help/how-to-ask),请考虑阅读并编辑你的问题,以便更清楚地了解你想要的内容。 – MikeC

+0

l不想要微笑或程序中的其他符号 – sinan

+1

魔法八球告诉我你正在试图弄清楚为什么你的代码在字符串结束后继续写入。 –

回答

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 

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

je stop 

jmp start      

所以,请把这个答案作为免费的调试。不过,我仍然投票决定把它作为一个副本来关闭。 :)

相关问题