Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;$VER: 99bottles.s v1.00 by Zeb (26-Aug-2018)
- output ram:99Bottles
- ProgStart:
- move.l 4.w,a6
- lea DosName(pc),a1
- moveq.l #0,d0
- jsr -$228(a6) ;OpenLibrary(a1,d0)exec
- move.l d0,DosName
- beq.b Fatal
- move.l d0,a6
- jsr -$3c(a6) ;Output()dos
- move.l d0,d6
- beq.b ClDos
- moveq.l #100,d7
- Loop: move.l d7,d4
- lea Bottle(pc),a4
- move.l d4,d5
- subq #1,d5
- divu #10,d5
- move.b d5,(a4)
- add.b #"0",(a4)+
- swap d5
- move.b d5,(a4)
- add.b #"0",(a4)
- cmpi #9,d4
- bls.b SingleDigit
- subq #1,a4
- SingleDigit:
- move.l d6,d1 ;Show the first bit
- lea Bottle(pc),a0
- move.l a0,d2
- moveq.l #9,d3
- jsr -$30(a6) ;Write(d1,d2,d3)dos
- cmpi #2,d7 ;Check for singular (remember, our counter is +1 due to our way of exiting the loop
- beq.b Singular
- lea Plural(pc),a0
- move.l d6,d1
- move.l a0,d2
- moveq.l #1,d3
- jsr -$30(a6) ;Write(d1,d2,d3)dos
- Singular:
- lea EndText(pc),a0
- move.l d6,d1
- move.l a0,d2
- moveq.l #21,d3
- jsr -$30(a6) ;Write(d1,d2,d3)dos
- subq.l #1,d7
- bne.b Loop
- ClDos: move.l a6,a1
- move.l 4.w,a6
- jsr -$19e(a6) ;CloseLibrary(a1)exec
- Fatal: moveq.l #0,d0
- rts
- DosName:
- dc.b 'dos.library',0
- even
- Bottle:
- dc.b 'XX bottle'
- even
- Plural: dc.b 's',0
- EndText:
- dc.b ' of beer on the wall',$a
- even
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement