Skip to content

Analyzing Disassembled and Decompiled Linear Algebra Functions

widberg edited this page Jan 27, 2024 · 6 revisions

A good way to see what a linear algebra function's/operation's disassembly looks like is to play around with GLM on Compiler Explorer. GLM is an open-source C++ math library that has all of the common linear algebra types and operations defined. You can add the GLM library using the "Libraries" tab in the compiler view, I also recommend adding the compiler flags -O3 -m32 to compile optimized x86_32 machine code. I have set up a playground here https://godbolt.org/z/WqKW69EEo with these prerequisites satisfied.

The GLM source code is also a useful resource for comparing decompilation. The dot product specialization definitions and cross product specialization definition can be found among other common geometric functions in glm/geometric.hpp. Common matrix functions are defined in glm/detail/func_matrix.inl and the operators defined on types, e.g. multiplication, are in the glm/detail directory. The documentation is easy to navigate and so is the code, so you shouldn't have a hard time finding anything.

Keep in mind that an optimizing compiler will inline functions and reorder instructions. When chaining these functions/operations the instructions for each may be interleaved with each other. This entangling can make it harder to reason about where one function/operation begins and ends from another. I find it helpful to clearly label the temporary variables and try to put the decompiled code in a more reasonable order in a text editor.

Home
FAQ

For FMTK Users and Mod Developers

Read the Docs

For FMTK Developers

Asobo BigFile Format Specification
Asobo Classes
      Animation_Z
      Binary_Z
      Bitmap_Z
      Camera_Z
      CollisionVol_Z
      Fonts_Z
      GameObj_Z
      GenWorld_Z
      GwRoad_Z
      Keyframer*_Z
      Light_Z
      LightData_Z
      Lod_Z
      LodData_Z
      Material_Z
      MaterialAnim_Z
      MaterialObj_Z
      Mesh_Z
      MeshData_Z
      Node_Z
      Omni_Z
      Particles_Z
      ParticlesData_Z
      RotShape_Z
      RotShapeData_Z
      Rtc_Z
      Skel_Z
      Skin_Z
      Sound_Z
      Spline_Z
      SplineGraph_Z
      Surface_Z
      SurfaceDatas_Z
      UserDefine_Z
      Warp_Z
      World_Z
      WorldRef_Z
Asobo File Format Idioms
Asobo CRC32
Asobo LZ Compression
Asobo Arithmetic Coding Compression
Asobo Save Game File Format Specification
Asobo Audio Formats
TotemTech/ToonTech/Zouna/ACE/BSSTech/Opal Timeline
Zouna Modding Resources
Miscellaneous

Clone this wiki locally