DOS调试像32位x86程序集 [英] DOS debug like program for 32-bit x86 assembly

查看:132
本文介绍了DOS调试像32位x86程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多人可能会记得旧的DOS程序 - 调试。虽然在许多方面已经过时了,但其中一个很好的事情是,可以轻松找到给定指令的字节序列,而无需执行编写程序,编译,反汇编,检查文件内容的步骤。 ..输入指令,然后转储指令地址。 调试令人遗憾的是没有32位指令。



有没有人知道一个与32位x86指令类似的工具?我不想经历整个编译过程;我只需要输入几个指令,并且显示指令的长度和字节序列。

解决方案

p> DOS debug 是一个交互式汇编器以及一个调试器,输入汇编代码导致该行被立即转换为机器代码 - 这是您转出的。 p>

所以你需要的是使用脚本或批处理文件自动化你最喜欢的汇编器。



这是一个bash函数我想出了一两分钟,使用流行的 nasm 汇编器:

  opcode(){
echo $ *> tmp.S&& nasm tmp.S -o tmp.o&&& od -x tmp.o
rm -f tmp.o tmp.S
}

不到一秒钟。调用如下所示:

  $ opcode mov eax,[ebx] 
0000000 6667 038b
0000004
$ opcode fadd st0,st1
0000000 c1d8
0000002

不辉煌,但您可以调整od命令行以获得更好的输出。只要你告诉它使用一个简单的二进制输出格式,这个想法就适用于任何命令行汇编器。


Many of you may recall the old DOS program--debug. Though outdated in many respects, one of the nice things about it was that one could easily find the byte-sequence for a given instruction without having to go through the steps of writing a program, compiling, disassembling, examining the file contents, .... Enter the instruction, then dump the instruction address. 'debug' regrettably does not do 32 bit instructions.

Does anyone know of a tool that does something similar for 32-bit x86 instructions? I don't want to go through the whole compile process; I just need to be able to enter a couple of instructions and have it spew out the length of the instruction and its byte sequence.

解决方案

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:

opcode() {
  echo $* > tmp.S && nasm tmp.S -o tmp.o && od -x tmp.o
  rm -f tmp.o tmp.S
}

Takes less than a second. Invocation looks like this:

$ opcode mov eax, [ebx]
0000000 6667 038b
0000004
$ opcode fadd st0,st1
0000000 c1d8
0000002

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.

这篇关于DOS调试像32位x86程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆