string - 如何在 .COM 可执行文件中以相反顺序打印字符串?

标签 string assembly dos reverse x86-16

我刚刚开始学习汇编语言,我正在尝试以相反的顺序打印“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/

相关文章:

DOS调试.exe : Restricted areas of memory?

c - 在 C 的 DOSBOX 中没有可用于 malloc 的内存

c - 在 C 中初始化字符串的正确方法

string - 根据值搜索对象中的未知属性

assembly - 汇编中的源代码索引

assembly - 4字节的汇编指令如何编码4字节的内存地址?

javascript - 用于检查多个匹配项的正则表达式

c - 为什么我不能重用 c = getchar();在 str1 上使用后在 str2 上? (C)

c - -Xassembler 和 -Xpreprocessor 示例

c++ - 在 Turbo C++ 3.0 的 16 位 Dos 5 上使用 inp()