如何在.COM可执行文件中以相反的顺序打印字符串? [英] How to print a string in reverse order in a .COM executable?
问题描述
我刚开始学习汇编语言,我正尝试以相反的顺序打印"hello world",这意味着"dlrow olleh".问题是我只得到第一个字母作为输出,并且顺序仍然不变根本!作为一个新手,很多事情对我来说是未知的,我正在做很多错误,由于缺乏知识而无法识别它们,因此任何带有适当解释的答案将不胜感激!这是我的代码:
I have just started to learn assembly language and i am trying to print "hello world" in reverse order that means "dlrow olleh".the problem is i am getting only 1st letter as output and the order is still same no change at all!As a newbie many thing is unknown to me and i am doing lots of mistakes and i am unable to identify them due to lack of knowledge.So any answer with proper explanation will be appreciated!Here is my code:
name "hi" ; can anybody explain what is the use of this?
org 100h
jmp start ; jump over data declaration
msg db "1Hello, World!",0;last character
msg1 db "1"
Mov SI,13;lenght of the string
start:
Mov AL,msg[SI]
DEC SI
Mov ah ,0eh
int 10h
mov BL,msg1
CMP msg[SI],BL;comparing to get the end of the string
je stop
jmp start
stop:
mov ah, 0
int 16h ; wait for any key....
ret ; return to operating system.
我只输出第一个字母"1",但是我希望以相反的顺序得到整个字符串
i am getting output only "1" which is the first letter,but i expected to get the whole string in reverse order
推荐答案
jmp start ; jump over data declaratio
...
Mov SI,13;lenght of the string
start:
问题出在这里-您没有初始化寄存器si
here is the problem - you're not initializing register si
您需要使用以下内容:
jmp init ; jump over data declaratio
...
init:
Mov SI,13;lenght of the string
start:
这篇关于如何在.COM可执行文件中以相反的顺序打印字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!