Log in

View Full Version : Writing an OpCode Generator


foxthree
March 8th, 2002, 14:19
Hi:

I was just wondering about OpCodes and stuff and I thought it would be a cool idea to write an OpCode generator for Intel Pentiums. Not that there aren't tools out there already but I downloaded a couple of them and they didn't look that impressive to me (bad UI and bad bad bugs :-<

So what would it take to write a OpCode Generator? Any good pointers to information is gratefully accepted. (if the site has source code even better ;-))

Thanks,

--Signed
FoxThree

ZaiRoN
March 8th, 2002, 20:03
hi foxthree,
if i remember well there's an opcode generator written by Neural Noise with the source code. you could try it...

bye
ZaiRoN

DakienDX
March 8th, 2002, 21:03
Hello foxthree !

What do you exactly mean by a OpCode Generator?

A program which generates opcodes from text? (Why not try TASM/MASM?)

A program which checks if given binary data is valid code?

A program which creates code to make debugging harder?

foxthree
March 9th, 2002, 08:30
Hi DakienDX:

I was more referring to the one like Zairon... you input some assembly instructions and it generats OPcodes for that. However, the problem with some of the Opcode generators are that they're buggy and generate wrong opcodes at times.

Yes, I came to know that it would something similar to writing an assembler. I wouldn't want to write a full-fledged assembler... not yet ;-). Just one that generates OpCodes.

It was just for my learning...

Signed,
-- FoxThree

Kayaker
March 9th, 2002, 08:55
Hi foxthree

You could take a look at LDE32 (Length Disassembly Engine) by Z0mbie. It's an ASM module you can incorporate into your code. Would require a loader for the target file, then you give it an address to partially disassemble and it returns the proper opcodes from the sequence of bytes starting at that address.

To actually get the disassembled text you'd need to pass the opcodes to a disassembler. I found LDE32 lacked support for some recent P6 opcodes, but it's fine for the basics.

But if you're going for the full disassembler route, it'd be best to look into something like the NASM source or Borg or some other sourced disassembler.

Just out of curiousity, what other Opcode generators have you found other than Neurals OpGen? I can't think of any others per se.

Actually, I just noticed Z0mbie has a couple of updates and there's 2 interesting opcode programs (using his LDE32) used here:

http://z0mbie.host.sk/opcodes.html

Kayaker

foxthree
March 9th, 2002, 12:05
Hi Kayaker:

I found this too at protools.cjb.net. However link is broken and a Google search revealed nothing :-<


oPcodeR by Cool McCool. 16.IV.2001.
oPcodeR 1.1 (297K).

News:
- added support for ADC, ADD, ARPL, BSWAP, IDIV, LDS, LES, LFS, LGS, LSL, LSS, SBB, SFENCE, SUB

oPcodeR is another opcode generator. But it doesn't simply generate opcodes from values given in comboboxes. It occupies some sort of built-in parser, which generates byte series from typed instructions.

Signed,
-- FoxThree