Skip to content

About: flat.cpp

chris03-dev edited this page Sep 22, 2020 · 3 revisions

Note: The source code structure is not yet fully documented. A table of contents will be provided when it is done.


This file contains source code for compiling a .flat file into assembly. Many of these operations require functions from linemod.cpp.

In a nutshell, the code performs the following operations:

  1. Get the contents of an input file.
  2. Parse the contents to assembly code (in Intel syntax) in string streams.
  3. Insert the string streams, in order, to an assembly output file.
  4. Call the assembler to convert the output file to an executable binary.

Each operation will be explained in detail below...

  • Startup

  • Preprocessor loop (Read all Lines)

    • Read line
    • Remove comments on line
    • Insert line to vector list
  • Parsing preparations

    • Variable lists (Compiler Data)
    • Vartype enum
  • Parsing loop (Convert lines to data for assembly code)

    • Assembly flag
    • Other
      • Global variable declaration
      • Function declaration
        • Stack variable declaration
      • Function call
      • Arithmetic parsing
      • Reserved keywords
  • Assembly file creation

    • Assembly data section
    • Assembly text section
  • End

flathill Info

Software How-to

About

  • flat.cpp
  • linemod.cpp
  • compile-[win/nix].*

Clone this wiki locally