Skip to content

About

Lissajous curves animation written in x86-64 assembly

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Lissajous curves (x86-64 assembly)

The project is a hybrid C and assembly program which animates Lissajous curves and lets a user interact with them by adjusting parameters (A, B, a, b) in real time.

image

It's split in two main parts:

  1. C code main.c handles user's input, memory allocation and graphics rendering using the SDL2 library,

  2. Assembly code lissajous.s performs the mathematical calculations for generating the Lissajous curves:

    • x(t) = A * sin(a * t + δ/2π)
    • y(t) = B * sin(b * t)

It computes the coordinates (x, y) for every dt = 0.00025 in [0.0, 1.0] using the sine function approximated by a 9th degree minimax polynomial, which coefficients were computed using the Remez algorithm and uses the SSE vector instructions, instead of x87 FPU, for performing 4 single-precision floating point calculations simultaneously to achieve better performance (which can be improved even more by transitioning to AVX/AVX-512).

The program is designed to run on Linux operating systems and follows the Unix System V x86-64 ABI for compatibility.

This project demonstrates how to combine low-level assembly programming with high-level graphics rendering to create visually appealing results and has taught me that every line of code has it's own enormous side effects, even if it's just a simple mov instruction, that the x86-64 architecture is a (really) complex beast with many intricacies to consider when writing assembly code, and last but not least, that approximating functions with Taylor series can sometimes be a really bad idea.

Requirements:

  • x86-64 compatible CPU
  • Linux operating system (tested on Ubuntu 24.04.4 LTS)
  • SDL2 development libraries
    • For Debian-based distributions : sudo apt install libsdl2-dev
    • Detailed installation guide is here.

For building

  • NASM assembler
  • Make utility
  • GCC compiler (for linking)

Huge thanks to

About

Lissajous curves animation written in x86-64 assembly

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages