A low-level betting dice game written entirely in x86 32-bit MASM Assembly with C++ interop
Assembly Dice Game is a console-based dice betting game written using x86 32-bit MASM Assembly. The project was built as a hands-on exploration of CPU register manipulation, the stack frame, procedural call conventions, and direct memory management.
Gameplay is straightforward: the player is given a starting balance of $100 and places bets before each roll of two dice six sided dice. If the rolled total matches the bet target, winnings are added; otherwise the stake is lost. The player can save progress to disk and reload it in a future session. This demonstrates file I/O at the assembly level without any standard library wrappers.
A small C++ helper module bridges the Irvine32 library, handling platform-specific I/O and pseudo-random number generation that would otherwise require hand-writing OS interrupt calls. The project was built as part of the final for a Computer Architecture and Assembly class.
Game state — balance, current bet, dice values — is managed directly in EAX, EBX, ECX, EDX registers and stack-allocated locals, with no heap allocation.
MASM PROC directives define subroutines with explicit PUSH/POP stack frame management, mirroring how compilers generate function prologues and epilogues.
Irvine32's RandomRange procedure generates pseudo-random dice values (1–6), invoked via C++ linkage from the MASM module.
Player balance and session data are written to and read from a binary file using DOS-style file I/O procedures, demonstrating low-level file handling.
View the full MASM source, C++ helper, build instructions, and project report on GitHub.
View on GitHub