在两个不同的行上打印一个字符串
我试图让我的程序在两个不同的行上显示一个字符串。
这是一个 .com 程序,我正在使用 A86 汇编器。
jmp start ; This will start the program
;============================
msg db "Hello Word.$" ; A string variable
msg db "Michael J. Crawley$" ; A string variable with a value.
;============================
start:
mov ah,09 ; subfunction 9 output a string
mov dx,offset msg ; DX for the string
int 21h ; Output the message
int 21h ; Output the message
exit:
mov ah,4ch
mov al,00 ; Exit code
int 21h ; End program
I am trying to get my program to display a string on two different lines.
This is a .com program and I am using A86 assembler.
jmp start ; This will start the program
;============================
msg db "Hello Word.$" ; A string variable
msg db "Michael J. Crawley$" ; A string variable with a value.
;============================
start:
mov ah,09 ; subfunction 9 output a string
mov dx,offset msg ; DX for the string
int 21h ; Output the message
int 21h ; Output the message
exit:
mov ah,4ch
mov al,00 ; Exit code
int 21h ; End program
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是您的具体问题:
msg
(a86 会对此感到厌烦)。这些点的解决方案(不提供实际代码)。
msg2
。msg2
加载到 dx 中。更新:由于其他一些有用的灵魂已经提供了源代码,这是我的解决方案。我建议您从中学习并修改您自己的代码以执行类似的操作。如果您从公共网站逐字复制它以进行课堂作业,您几乎肯定会因抄袭而被抓:
此输出:
Here are your specific problems:
msg
twice (a86 will barf on that).The solutions to those points (without providing the actual code).
msg2
.msg2
into dx before calling int21 for the second time.Update: Since some other helpful soul has already provided source, here's my solution. I would suggest you learn from this and modify your own code to do a similar thing. If you copy it verbatim from a public site for classwork, you'll almost certainly be caught out for plagiarism:
This outputs:
msg 的两种定义?
Two definitions of msg?
我不熟悉 a86,但熟悉 NASM 和 NASM。 MASM 在 com 程序的开头需要一个“org 100h”汇编指令。现在的情况是,offset msg 是 0x2,它将尝试从程序段前缀的第二个字节(一个 16 位字,保存可用内存顶部的段)开始打印。
I'm not familiar with a86, but with NASM & MASM you need an "org 100h" assembler directive at the beginning of a com program. The way it is now, offset msg is 0x2, and that'll try to print from the second byte of the program segment prefix (a 16 bit word that holds the segment of the top of memory available to you).