tags:

views:

65

answers:

3

Is there a way to write a program using pure x86 intel opcodes instead of the assembly mnemonics and instructions and then compile it with ML and LINK. For example if I try and write a 55 instead of push ebp ML thinks it is an integer. Does it require a special compiler or how would you write an opcode program and compile it.

+1  A: 

You can use db:

db CDh,19h

calls interrupt 0x19.

smilingthax
this is what I was looking for db 55h converts into a push ebp, how would I get it to recognize the 8B EC, it looks like that would take a dw but how do i input it as two seperate codes?
alphadev
You separate them with comma?
smilingthax
then i get an undefined symbol ECh?
alphadev
"db 8Bh,ECh" should work, but I can't test it here.
smilingthax
same thing, I am using ML and LINK with VS 2010 if you get chance to try later, if not no worries.
alphadev
A: 

Assembler's job is to translate the mnemonix to binary values. x86 is a CISC instruction set with long history, so this translation is quite difficult to do manually.

The linking process is even worse, it creates the final executable, which implies creation of lots of structures. This is much more difficult to do and mentain manually.

If you really want to write something using opcodes, take a hex-editor (or even a notepad, if you know all the ASCII codes :) ) and write a .COM program. Anything more complicated (.exe) would be overkill.

ruslik
A: 

The short answer is that it is possible to write a program using only opcodes. As smilingthax demonstrates, you still need an assembler, or other tool to output the binary values of each opcode.

You are going to need to refer to the Intel documentation in order to find out the opcodes for each assembly memmonic. This information is contained in the Intel(R) Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual.

Crippledsmurf