Tic Tac Toe
RepositoryI developed this Tic Tac Toe implementation in x86 Assembly to gain a deeper understanding of low-level CPU operations and memory management. The project evolved from a 16-bit DOS application using BIOS interrupts to a 64-bit Linux version leveraging modern system calls. Through this process, I mastered register-level logic, stack manipulation, and the intricacies of direct hardware interaction.
Dual-Architecture Implementation
The project features two distinct versions: a 16-bit version designed for the emu8086 emulator and a modern 64-bit version for Linux. The DOS version relies on INT 10h for video control and INT 21h for standard I/O, while the Linux version uses SYSCALL 1 (sys_write) and 0 (sys_read). This transition allowed me to compare legacy real-mode programming with contemporary protected-mode execution.
Win Detection Logic
The CHECK method is the heart of the game logic, evaluating the board state after every turn. It rigorously compares memory values across eight possible winning combinations (rows, columns, and diagonals). By using conditional jumps like JNZ (Jump if Not Zero), the program efficiently branches through validation steps, setting the DONE flag to 1 if a victory is detected.
Terminal UI and Input Validation
To create a seamless user experience, I implemented custom rendering and validation routines. In the 64-bit version, I used ANSI escape sequences to clear the screen and position the cursor, mimicking a modern terminal UI. The TAKEN method ensures game integrity by preventing players from overwriting occupied cells, providing instant visual feedback before re-prompting for input.
Low-Level Challenges
One of the most significant challenges was handling raw terminal mode in Linux to capture single-character inputs without requiring the user to press Enter. This required manipulating the termios structure via ioctl system calls. Learning to manage the stack frame manually and understanding how 32-bit and 64-bit addresses are calculated in real-time was a pivotal moment in my development as a programmer.
Video Demonstration
External Media Required
This video requires third-party cookies from YouTube to be displayed. Accepting will enable all external media across the site.