使用 FASM 在汇编编程中打印
我正在尝试使用下面的代码打印一条消息:
org 100h
start:
jmp begin
begin:
mov ah, 9
mov dx, msg
msg db 'Ascii sign:.$'
int 21h
finish:
mov ax, 4c00h
int 21h
它能够编译,但根本不显示任何内容。但是,如果我将“msg db 'Ascii sign:.$'”行移到“jmp begin”下方,则可以显示该消息。
我想知道这背后的逻辑。我在哪里声明消息有什么不同吗?
这只是出于好奇,谢谢!
I am trying to print a message by using the code below:
org 100h
start:
jmp begin
begin:
mov ah, 9
mov dx, msg
msg db 'Ascii sign:.
It is able to compile but it display nothing at all. But if I move the line "msg db 'Ascii sign:.$'" below "jmp begin", the message is able to display.
I want to know the logic behind this. Does that make a difference where I declare the message ?
This is just out of curiosity, thank you!
int 21h
finish:
mov ax, 4c00h
int 21h
It is able to compile but it display nothing at all. But if I move the line "msg db 'Ascii sign:.$'" below "jmp begin", the message is able to display.
I want to know the logic behind this. Does that make a difference where I declare the message ?
This is just out of curiosity, thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。现在,
msg
定义在代码中间,CPU 将尝试执行它。您通常希望在数据段中单独定义数据。我不记得 FASM 的语法,但使用 MASM 或 TASM,您通常会执行以下操作:Yes. Right now,
msg
is defined in the middle of the code, where the CPU will attempt to execute it. You normally want to define data separately, in the data segment. I don't remember the syntax for FASM, but with MASM or TASM, you'd normally do something like this:如果您确实必须将字符串放在代码部分中,那么只需跳过它们即可。
If you really must have your strings in the code section, then just jump over them.