Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How do I create a simple roll 1 dice (die) in x64 Assembly GAS/AT&T syntax?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Random subroutine takes in a single argument in the %rax register. Use 6 in %rax to produce 6 different values.

The following is the basic algorithm:

* Starts with $100 balance default and loops until player is out of money then exits.
1. Print to screen "Welcome to Dice"
2. Money > 0
true: continue to number 3
false: output "You lost all your money. Game over" Go to number 11
3. Print to screen "Enter your bet"
4. Scan in bet
5. Random calculate player roll (random(6)
6. Random calculate house roll (random(6)
7. Output "You rolled a (value) player"
8. Output "House rolled a (valuie) house"
9. Check player > house
true: money = money+bet output "You win!"
false: money = money-bet output "You lose!"
10. Go back to (loop) number 2.
11. End program
reply
    Bookmark Topic Watch Topic
  • New Topic