How Do Assemblers Map x86 Instruction Mnemonics to Binary Machine Instructions?

前端 未结 3 443
面向向阳花
面向向阳花 2021-02-07 18:06

I\'m interested in writing an x86 assembler. I\'m wondering what is a good way to map x86 assembly mnemonic instructions (using an Intel-like syntax) into the corresponding bina

3条回答
  •  再見小時候
    2021-02-07 18:28

    Do you want to understand the physical mapping of mnemonics to machine code? If so volume 2A & 2B of the the Intel IA32/IA64 reference manuals describe the binary format of x86 machine code .

    The x86 instruction set page on Wikipedia has a compact listing of all the instructions categorized by when they were introduced, which might help you prioritize what to implement first.

    However, if you are asking about how to go about parsing an assembly code text file to get to the point where your program could start writing out machine code then you basically need to understand how to write a compiler. The tools lex and yacc are good places to start but if you don't know how build a compiler you'll also need to get a book. I think the Dragon book is the best one out there but there are any number of other books you could use, SO has plenty of recommendations.

提交回复
热议问题