Bidirectional grammars for machine-code decoding and encoding

Gang Tan, Greg Morrisett

Research output: Chapter in Book/Report/Conference proceedingConference contribution

1 Scopus citations


Binary analysis, which analyzes machine code, requires a decoder for converting bits into abstract syntax of machine instructions. Binary rewriting requires an encoder for converting instructions to bits. We propose a domain-specific language that enables the specification of both decoding and encoding in a single bidirectional grammar. With dependent types, a bigrammar enables the extraction of an executable decoder and encoder as well as a correctness proof showing their consistency. The bigrammar DSL is embedded in Coq with machine-checked proofs. We have used the bigrammar DSL to specify the decoding and encoding of a subset of x86-32 that includes around 300 instructions.

Original languageEnglish (US)
Title of host publicationVerified Software
Subtitle of host publicationTheories, Tools, and Experiments - 8th International Conference, VSTTE 2016, Revised Selected Papers
EditorsSandrine Blazy, Marsha Chechik
PublisherSpringer Verlag
Number of pages17
ISBN (Print)9783319488684
StatePublished - 2016
Event8th International Conference on Verified Software: Theories, Tool and Experiments, VSTTE 2016 - Toronto, Canada
Duration: Jul 17 2016Jul 18 2016

Publication series

NameLecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Volume9971 LNCS
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349


Other8th International Conference on Verified Software: Theories, Tool and Experiments, VSTTE 2016

All Science Journal Classification (ASJC) codes

  • Theoretical Computer Science
  • Computer Science(all)


Dive into the research topics of 'Bidirectional grammars for machine-code decoding and encoding'. Together they form a unique fingerprint.

Cite this