Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BR main
- sticks: .BLOCK 2
- take: .BLOCK 2
- ;
- main: LDA 21,i
- STA sticks,d
- LDA 0,i
- STA take,d
- STRO msg1,d
- CHARO '\n',i
- STRO msg2,d
- CHARO '\n',i
- while: STRO msg3,d
- DECO sticks,d
- STRO msg4,d
- CHARO '\n',i
- DECI take,d
- LDA take,d
- CPA 1,i
- BRLT while
- CPA 3,i
- BRGT while
- LDA sticks,d
- SUBA take,d
- STA sticks,d
- BR if1
- if1: LDA sticks,d
- CPA 0,i
- BRLE win1
- BR else
- else: LDA sticks,d
- ANDA 0x0003,i
- STA take,d
- if2: LDA take,d
- CPA 0,i
- BREQ if3
- if3: LDA 1,i
- STA take,d
- STRO msg3,d
- DECO sticks,d
- STRO msg6,d
- DECO take,d
- CHARO '\n',i
- LDA sticks,d
- SUBA take,d
- STA sticks,d
- if4: LDA sticks,d
- CPA 0,i
- BREQ win2
- BR while
- win1: CHARO '\n',i
- STRO msg5,d
- BR stop1
- win2: CHARO '\n',i
- STRO msg7,d
- stop1: STOP
- msg1: .ASCII "There are 21 sticks in a pile. Each of us will take 1,2 or 3 sticks.\x00"
- msg2: .ASCII "The player who takes the last stick wins. You can go first.\x00"
- msg3: .ASCII "There are \x00"
- msg4: .ASCII " sticks left. Do you want to take 1,2 or 3?\x00"
- msg5: .ASCII "You took the last stick. You won!\x00"
- msg6: .ASCII " sticks left. I took \x00"
- msg7: .ASCII "I took the last stick. I won!\x00"
- .END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement