1

I am trying to write binary opcodes, but I can't in a text editor as 1s and 0s because:

1 or 0 on a text editor ends up being stored as the literal ASCII equivalent code on the storage medium, not the individual bit values as part of a machine instruction. I want to write a program in machine code to be executable directly to the CPU without assembling/etc. However, there's only one way I can think of:

I can flip the conundrum backwards, and instead of worrying about the formation of bits, I can write ASCII characters and save them in a text editor so long as their ASCII-binary equivalent matches the identical configuration of an opcode byte(s) for the target machine. But then the problem arises again ... there is not an existing one-byte ASCII character that can match every possible combination of bits within an opcode, so I can't code this way.

For me to write in machine code, I'd need a way of directly placing the right formation of bits that make up each byte(s) and instruction(s).

How could I do this?

CORRECTION: I am not trying to write a single bit at a time (not possible in x86), but get a byte configured with the correct bits in order to be stored that make up the correct machine instructions.

closed as off-topic by jvoisin, joxeankoret, 0xC0000022L, Jason Geffner, ixje Feb 22 '14 at 12:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on software development are off-topic here, but can be asked on Stack Overflow." – jvoisin, 0xC0000022L, Jason Geffner, ixje
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This sounds like a development question. – 0xC0000022L Feb 21 '14 at 20:28
  • 1
    Either you don't explain yourself correctly or we're being trolled. – joxeankoret Feb 21 '14 at 20:30
  • @joxeankoret What am I missing? I think I explained enough - I need to formulate the bits of a byte, and wish to do so by structuring the bits manually of a byte to match that of an opcode. In a text editor this can't be done, and hex editors only allow whole bytes; I need the correct representation down to the bits. – Tracker Boots Feb 21 '14 at 20:31
  • @0xC0000022L It's not. – Tracker Boots Feb 21 '14 at 20:32
  • 1
    Since x86 opcodes all contain a whole number of bytes, you may as well use a hex editor and enter your instructions byte by byte. Entering the correct hexadecimal number will most certainly ensure "correct representation down to the bits". – higaki Feb 21 '14 at 23:54

Browse other questions tagged or ask your own question.