Created with Iniw
A classic text‑based betting game written in x86 Assembly, playable in an emulator like EMU8086.
Test your luck, manage your virtual bankroll, and experience retro computing at its finest.
Gambling Dice is a terminal‑based dice‑rolling game developed entirely in x86 Assembly.
The player starts with $1000 and can bet on a number between 1 and 6. After placing a bet, a random dice roll determines whether they win or lose.
The game continues until the player quits or runs out of money.
This project was created for educational and technical demonstration purposes, showcasing low‑level programming concepts in a fun, interactive way.
It embraces the retro computing aesthetic reminiscent of early DOS‑based text games.
- Betting System – Start with a virtual bankroll of $1000.
- Random Dice Generator – Uses system time (INT 1Ah) to generate unpredictable rolls.
- Win / Lose Logic – Compare player’s guess against the rolled number.
- Quick and Dynamic Visual Feedback – Colored screen segments indicate win or loss.
- Multiple Rounds – Play repeatedly until you decide to quit or go bankrupt.
- ASCII Dice Animation – A special rolling animation adds excitement.
- Money Tracking – Balance updates automatically after each round.
- Platform – Designed for EMU8086 and compatible emulators.
The game features a terminal‑based interface with pixel‑graphics‑like animations.
- Number keys (1–6) – Choose your bet number.
- Enter bet amount – Must be ≤ current money.
- 0 – Exit the game.
- Any key – After a result, press any key to continue.
The following flowchart illustrates the game logic:
Challenge: x86 Assembly has no built‑in random number generator; ensuring fairness was tricky.
Solution: Used the system clock’s low‑level ticks (via INT 1Ah) to seed a pseudo‑random algorithm, then applied modular arithmetic to constrain the result to 1–6.
Challenge: Tracking bets, balance, and dice results simultaneously with only a handful of registers.
Solution: Reserved memory addresses using .data directives to persist data and minimized register dependency.
Challenge: Creating smooth animations without hardware‑level timing control.
Solution: Implemented a loop‑based delay for the animation and leveraged terminal text printing for a responsive feel.
- Low‑Level Constraints: Working with Assembly reinforced the importance of manual memory and register management.
- Debugging Rigor: Even small errors (e.g., incorrect
CMPoperands) could cause crashes, emphasizing systematic testing. - Creative Problem‑Solving: Hardware limitations drove innovative solutions, such as using system interrupts for randomness.
- Expanded Gameplay – Add more casino games (Blackjack, Roulette, etc.).
- Visual Upgrades – Colorized text warnings when money runs low, improved win/lose animations, and a main menu for selecting games.
- Code Optimization – Refactor repetitive logic into macros/subroutines, especially for the animation sequences.
- Dice logic: Real Python – Python Dice Roll
- Betting system reference: GitHub Gist by zemmyang
- Install EMU8086 (or any x86 emulator that supports the required interrupts).
- Load the
ASM_GAME.asmsource file. - Assemble and run the program.
- Follow on‑screen instructions to play.
Iniw41
GitHub: @Iniw41
This project is open‑source and available under the MIT License.





