16位asm指令集

发布于 2024-12-07 02:36:54 字数 128 浏览 1 评论 0原文

COM 文件中使用哪组指令?我以为是8086,但看来我错了。在我发现的 8086 手册中,shl 只能接受 1 或 cl 作为其第二个参数,而 1 以外的立即值对我来说效果很好。如果有必要的话,我正在使用 NASM。
感谢您抽出时间。

What set of instructions is used in COM files? I assumed it was 8086, but it seems that I was wrong. In a 8086 manual I found, shl can only accept 1 or cl for its second argument, while immediate values other than 1 work fine for me. In case it matters, I'm using NASM.
Thanks for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一绘本一梦想 2024-12-14 02:36:54

这是那些有趣的问题之一,而且答案总是具有误导性。

真正的 DOS COM 文件没有标头,并且必须适合单个内存段,因为它没有重定位信息,DOS 必须将文件放在需要的位置,因此兼容(与 x86)的唯一真正方法是使用 8086 兼容组件。
编辑:澄清上述内容,这是因为 8086 没有内存页。

您当然可以在 286/386 操作数中进行编译,因为一旦程序运行,DOS 中就没有执行运行时来阻止您并说“不,您不能这样做,这是一条 386 指令”。

有趣的是,这也是 COM 文件在 Windows7 x32 或 Windows7 x64 中不经常工作的部分原因。

由于 DOS 的工作方式,当您执行 .com 文件时,command.com 被卸载,然后重新加载,因此本质上您的 .com 文件可以访问系统的所有内存,理论上可以使用 DOS 内存扩展器,例如 Phar lap 的 DOS/4GW我想到了 CWSDPMI。

长话短说;您可以使用当前系统支持的任何类型的命令,但您应该只使用 16 位 x86 兼容命令。

如果上面的内容听起来像 PITA,那是因为它确实是,我记得:) 这也是 .EXE 格式很快变得非常流行的原因。

This is one of those funny questions and as always the answers are misleading.

a true DOS COM file has no headers and has to fit inside a single segment of memory, because it had no relocation information, DOS had to put the file where it needed, and so the only true way of being compatible (with x86) was to use 8086 compatible assembly.
Edit: To clarify the above, this is because the 8086 didn't have memory pages.

You could certainly compile in 286/386 operands in, as once the program is running, there's no executive runtime in DOS to stop you and say 'no you can't do that, it's a 386 instruction'.

Which, funnily enough, is part of the reason why COM files don't work very often in Windows7 x32 or at all in Windows7 x64.

Because of way DOS worked, command.com was unloaded when you execute your .com file, and reloaded afterwards, so essentially your .com file could access all memory of the system, and in theory use DOS memory extenders like Phar lap's DOS/4GW and CWSDPMI come to mind.

Long story short; you could use any sort of commands that the current system could support, but you should only use 16-bit x86 compatible commands to be sure.

If the above sounds like a PITA, it's because it was, I remember :) It's also why the .EXE format got very popular very quickly.

鸢与 2024-12-14 02:36:54

真正的 COM(我不会讨论实际上是 EXE 等的 COM)仅意味着它是一个简单的 DOS 可执行文件。无论支持什么指令集都可用。我曾经在 8088 到 i486 上进行 DOS 编程(COM 和 EXE),并且在该模式下任何合法的指令都可以使用。例如,当我的目标是“16位”(技术上应该称为“实模式”)DOS时,我经常使用32位字符串指令和立即推送。

A true COM (I won't get into COMs that are actually EXEs, etc) just means it's a simple DOS executable. Whatever instruction set is supported is available. I used to do DOS programming (both COM and EXE) on 8088 up through i486 back in the day, and whatever instructions are legal in that mode, you can use. For example, I often used 32-bit string instructions and immediate pushes when my target was "16-bit" (technically should be called "real mode") DOS.

明明#如月 2024-12-14 02:36:54

COM 文件有两种主要类型。一种设计为在 MS-DOS 中运行,另一种设计为在 CP/M OS 中运行。据我所知,DOS COM 文件应该是基于 x86 的。根据 Wikipedia,CP/M COM 文件可能是 8085、8080 或 Z80 指令。正如另一个答案提到的,COM只是一种简单的可执行格式,可以使用任何受支持的底层指令集。

就 SHL 指令而言,现代 x86 硬件(可能是 x64)似乎支持对该指令使用立即数。不过,当我仅查看 8086 文档时,我找不到对它的引用,因此它一定是在某个时候添加的。以下是一些详细介绍此说明的参考资料:

http:// /siyobik.info/main/reference/instruction/SAL%2FSAR%2FSHL%2FSHR

http://ref.x86asm.net/coder32.html

There are two main types of COM files. One was designed to run in MS-DOS, the other was designed to run in the CP/M OS. As far as I know, the DOS COM files should be x86 based. CP/M COM files could potentially be 8085, 8080, or Z80 instructions according to Wikipedia. As another answer mentioned, COM is just a simple executable format, and can use any supported underlying instruction set.

In terms of the SHL instruction, it seems that modern x86 hardware (perhaps x64) supports using an immediate value for this instruction. I couldn't find reference to it when looking just at 8086 docs, though, so it must have been added at some point. Here's a couple of references which go into some detail on this instruction:

http://siyobik.info/main/reference/instruction/SAL%2FSAR%2FSHL%2FSHR

http://ref.x86asm.net/coder32.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文