Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. BR main
  2. sticks: .BLOCK 2
  3. take: .BLOCK 2
  4. ;
  5. main: LDA 21,i
  6. STA sticks,d
  7. LDA 0,i
  8. STA take,d
  9. STRO msg1,d
  10. CHARO '\n',i
  11. STRO msg2,d
  12. CHARO '\n',i
  13. while: STRO msg3,d
  14. DECO sticks,d
  15. STRO msg4,d
  16. CHARO '\n',i
  17. DECI take,d
  18. LDA take,d
  19. CPA 1,i
  20. BRLT while
  21. CPA 3,i
  22. BRGT while
  23. LDA sticks,d
  24. SUBA take,d
  25. STA sticks,d
  26. BR if1
  27. if1: LDA sticks,d
  28. CPA 0,i
  29. BRLE win1
  30. BR else
  31. else: LDA sticks,d
  32. ANDA 0x0003,i
  33. STA take,d
  34. if2: LDA take,d
  35. CPA 0,i
  36. BREQ if3
  37. if3: LDA 1,i
  38. STA take,d
  39. STRO msg3,d
  40. DECO sticks,d
  41. STRO msg6,d
  42. DECO take,d
  43. CHARO '\n',i
  44. LDA sticks,d
  45. SUBA take,d
  46. STA sticks,d
  47. if4: LDA sticks,d
  48. CPA 0,i
  49. BREQ win2
  50. BR while
  51. win1: CHARO '\n',i
  52. STRO msg5,d
  53. BR stop1
  54. win2: CHARO '\n',i
  55. STRO msg7,d
  56. stop1: STOP
  57. msg1: .ASCII "There are 21 sticks in a pile. Each of us will take 1,2 or 3 sticks.\x00"
  58. msg2: .ASCII "The player who takes the last stick wins. You can go first.\x00"
  59. msg3: .ASCII "There are \x00"
  60. msg4: .ASCII " sticks left. Do you want to take 1,2 or 3?\x00"
  61. msg5: .ASCII "You took the last stick. You won!\x00"
  62. msg6: .ASCII " sticks left. I took \x00"
  63. msg7: .ASCII "I took the last stick. I won!\x00"
  64. .END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement