We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
DOS
debug
是一个交互式汇编器和调试器,输入汇编代码会导致该行立即转换为机器代码 - 这就是您转储的内容。因此,您所需要的只是使用脚本或批处理文件来自动化您最喜欢的汇编程序。
这是我使用流行的 nasm 汇编器在一两分钟内想出的 bash 函数:
花费不到一秒。调用看起来像这样:
不是很出色,但是您可以调整 od 命令行以获得更好的输出。只要您告诉它使用简单的二进制输出格式,这个想法就应该适用于任何命令行汇编器。
DOS
debug
was an interactive assembler as well as a debugger, entering assembly code resulted in that line being converted immediately to machine code - which is what you dumped out.So all you need is to automate your favourite assembler with a script or batch-file.
Here's a bash function I came up with in a minute or two using the popular nasm assembler:
Takes less than a second. Invocation looks like this:
Not brilliant, but you can tweak od command-line for better output. This idea should work with any command-line assembler as long as you tell it to use a simple binary output format.
FreeDOS Debug/X 是一个面向行的调试器,最初是作为 MS-DOS 调试的克隆而开发的。然而,它已经获得了对 32 位指令的支持。它的汇编器和反汇编器都完全支持至少486级指令。还包括对 386+ 寄存器的访问和显示。例如,该调试器支持实/虚拟 86 模式下的 32 位代码(使用
a32
或o32
前缀)。另一方面,DebugX 变体允许将调试器作为 DPMI 客户端运行,以加载和调试另一个 DPMI 客户端。要调试的客户端可以在 16 位或 32 位保护模式下运行。 FreeDOS 调试系列的以下所有成员都是如此。最初的 Debug/X 仍在不断开发中。它可以在 github 上找到: https://github.com/Baron-von -Riedesel/DOS-debug/releases
还有一个 fork 增强调试,它是非免费的。它位于 https://pcdosretro.github.io/enhdebug.htm
最后,我分叉了Debug/X 从 2008 年开始。基于这个代码库,我创建了 lDebug,它仍然是面向行的,但比其他任何一个都更先进。手册和版本链接在我的网站上: https://pushbx.org/ecm/web/ #projects-ldebug
FreeDOS Debug/X is a line-oriented debugger originally developed as a clone for MS-DOS Debug. However, it has gained support for 32-bit instructions. Both its assembler and disassembler fully support at least 486-level instructions. Access to and display of the 386+ registers is also included. This debugger, for one, supports 32-bit code (using
a32
oro32
prefixes) in Real/Virtual 86 Mode. For another, the DebugX variant allows running the debugger as a DPMI client to load and debug another DPMI client. The client to debug can run in 16-bit or 32-bit Protected Mode. This is true of all of the following members of the FreeDOS Debug family.The original Debug/X is still being developed from time to time. It can be found on github: https://github.com/Baron-von-Riedesel/DOS-debug/releases
There is also the fork Enhanced Debug, which is nonfree. It's available at https://pcdosretro.github.io/enhdebug.htm
Finally, I forked Debug/X starting in 2008. Based on this codebase I created lDebug, which is still line-oriented but is more advanced than either of the others. Manual and releases are linked on my website: https://pushbx.org/ecm/web/#projects-ldebug
在 linux,我使用一个名为
asm-link
的 shell 脚本,它有一个-d
选项来汇编+ 链接,然后使用 objdump -drwC -Mintel 进行反汇编。这是我的回答的一部分另一个问题。该脚本可以使用
nasm -f win64
移植到 Windows,或使用-f macho64
移植到 OS X,如果您愿意,甚至可以移植到 DOS。NASM 默认将
.text
部分放在文件顶部,而 GNU Binutilsld
默认将 ELF 入口点放在.text< 的开头。 /code> 部分,如果找不到
_start
符号,因此即使链接也可以使用绝对最小的.asm
源文件,您甚至可以在 GDB 和单个文件中运行它们-步。猫> foo.asm
...键入一些内容并按 CtrlD 是创建文件的一种方法,当然也是您最喜欢的轻量级编辑器。使用示例:
我在第二个命令行上实际输入的是
asm; -dn
.Alt. 调用之前命令中的最后一个标记,因此我不必重新输入文件名。由于我的系统没有任何以
asm
开头的其他命令,因此该命令的制表符补全功能可以正常工作。nasm -felf64
(由脚本传递,或-f elf32
如果您使用asm-link -m32
)意味着BITS 64< /code> (或
BITS 32
)用于汇编。GNU Binutils
objdump
的输出格式非常适合显示机器代码,其中的地址可以轻松查看长度,空格可以轻松查看字节边界。 (与将十六进制数字塞在一起的nasm -l /dev/stdout -f elf64 foo.asm
列表不同。)+ nasm ...
和+ ld< /code> 输出行来自 bash
set -x
。脚本的-n
选项使用 NASM 而不是 YASM;当我最初写它时,我通常使用YASM。我可能应该将默认值更新为 NASM。On linux, I use a shell script I call
asm-link
, which has a-d
option to assemble + link and then disassemble withobjdump -drwC -Mintel
. It's part of my answer on another question.The script could be ported to Windows using
nasm -f win64
or OS X using-f macho64
, perhaps even to DOS if you wanted that.NASM defaults to the
.text
section at the top of the file, and GNU Binutilsld
defaults to putting the ELF entry point at the start of the.text
section if it can't find a_start
symbol, so even linking works with absolutely minimal.asm
source files, and you can even run them in GDB and single-step.cat > foo.asm
... type some and hit CtrlD is one way to create a file, or of course your favourite light-weight editor.Example use:
What I actually type on the second command line is
asm<tab> -dn <alt-.>
.Alt. recalls the last token from previous commands so I don't have to retype the filename. And tab-completion for the command works since my system doesn't have any other commands that start with
asm
.nasm -felf64
(passed by the script, or-f elf32
if you useasm-link -m32
) impliesBITS 64
(orBITS 32
) for assembling.GNU Binutils
objdump
's output format is fairly nice for showing the machine code, with addresses that make it easy to see length, and spaces that make it easy to see byte boundaries. (Unlikenasm -l /dev/stdout -f elf64 foo.asm
listings which cram hex digits together.)The
+ nasm ...
and+ ld
output lines are from bashset -x
. The-n
option to the script uses NASM instead of YASM; back when I originally wrote it, I usually used YASM. I should probably update the default to be NASM.有一些简单的 32 位命令行调试器可供使用。根据您的描述,OllyDbg可能很适合您的需求。至少 Microsoft 的Windows 调试工具的某些版本包含名为 CDB 的工具,它代表 Commandline DeBugger (尽管我还没有验证链接版本是否包含它......)
There are a few simple, 32-bit command line debuggers to be found. Based on your description, OllyDbg might fit your needs well. At least some versions of Microsoft's Debugging Tools for Windows include one named CDB, which stands for Commandline DeBugger (though I haven't verified that the linked version includes it...)