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

问题描述

你们中许多人可能还记得老的DOS程序 - 调试。虽然在许多方面已经过时,关于它的好东西之一是,人们可以很容易地找到一个给定的指令字节序列,而无需经过编写程序,编译,拆卸,检查文件内容的步骤,.. 。输入的指令,然后倾倒指令地址。 调试遗憾的是没有做32位指令。

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.

有谁知道一个工具,它确实为32位x86指令类似的东西吗?我不想去贯穿整个编译过程;我只需要能够进入一对指令和具有它喷出出指令的长度和它的字节序列

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 调试是一个互动的汇编程序,以及一个调试器,进入装配code导致该行被立即转换成机器code - 这是你甩什么

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

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

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汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:52
查看更多