Jump to content

Generating executable machine code

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
steffanp

steffanp

    Newbie

  • Members
  • Pip
  • 1 posts
Hi.
I am (for learning reasons) trying to develop a very small programming language. My language compiler works by compiling the code written, to x86 assembly, and then "compiling" the assembly to machine code.

The problem is that I don't know how to do the last step. I have heard that each assembly instruction must be compiled to 8-bits that the CPU can understand. So compiling the following assembly code, would generate 2X8bits, like seen below.

mov ax, 1234h 00101000 //these 8bit strings are just guesses
mov bx, ax 10011010

Is my theory correct that all assembly instructions must be compiled to an 8bit code that the CPU can understand? If yes, does anyone know where to get a list of these 8bit codes for each x86 assembly instruction?

If I am completely wrong about everything, please write how assembly is really converted into machine code.

Thanks.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Usually, you would use an appropriate assembly compiler for your last step. I know Intel provides one.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
vernes

vernes

    Newbie

  • Members
  • Pip
  • 8 posts
sorry, no links alowed, first post

avr and microchip (2 brands of IC's often used by hobbyists) also use ic architectures based on intel's cpu's. And the communities around it might proof useful for getting technical information about it.

#4
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts
Basically you usually use the assembler, linker and loader provided by the platform. Assemblers are quite simple, there are basically direct translations between mnemonics and binary opcodes, just pick up the Intel developers manual from their site (they will probably send you a hard copy for free if you ask) and then write something that translates between them. You have to pick a binary output format (elf, coff, etc) as a target. Naturally pick a binary format that can be linked by your linker.

#5
vernes

vernes

    Newbie

  • Members
  • Pip
  • 8 posts
But he stated he wanted a list of the actual binairy code.
The reference pdf's I've seen in the AVR and MicroChip communiies had these.

#6
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts

vernes said:

But he stated he wanted a list of the actual binairy code.
The reference pdf's I've seen in the AVR and MicroChip communiies had these.

The Intel manuals have the opcodes and the mnemonics.