我刚刚开始学习汇编语言,我正在尝试以相反的顺序打印“hello world”,这意味着“dlrow olleh”。问题是我只得到第一个字母作为输出,并且顺序仍然相同没有变化完全!作为一个新手,很多事情对我来说都是未知的,我犯了很多错误,由于缺乏知识,我无法识别它们。因此,任何具有正确解释的答案将不胜感激!这是我的代码:
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”,这是第一个字母,但我希望以相反的顺序得到整个字符串
最佳答案
jmp start ; jump over data declaratio
...
Mov SI,13;lenght of the string
start:
问题在于 - 您没有初始化寄存器si
你需要使用类似的东西:
jmp init ; jump over data declaratio
...
init:
Mov SI,13;lenght of the string
start:
关于string - 如何在 .COM 可执行文件中以相反顺序打印字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26368586/