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.
It's split in two main parts:
-
C code
main.chandles user's input, memory allocation and graphics rendering using the SDL2 library, -
Assembly code
lissajous.sperforms 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.
- 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 Debian-based distributions :
- NASM assembler
- Make utility
- GCC compiler (for linking)
- Lasse for computing the coefficients for the sine approximations using the Remez algorithm: Fast MiniMax Polynomial Approximations of Sine and Cosine
- gdb
