Advertisement
Yesideez

99 Bottles.s

Aug 26th, 2018
1,575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;$VER: 99bottles.s v1.00 by Zeb (26-Aug-2018)
  2.  
  3.     output  ram:99Bottles
  4.  
  5. ProgStart:
  6.     move.l  4.w,a6
  7.     lea DosName(pc),a1
  8.     moveq.l #0,d0
  9.     jsr -$228(a6)   ;OpenLibrary(a1,d0)exec
  10.     move.l  d0,DosName
  11.     beq.b   Fatal
  12.     move.l  d0,a6
  13.     jsr -$3c(a6)    ;Output()dos
  14.     move.l  d0,d6
  15.     beq.b   ClDos
  16.  
  17.     moveq.l #100,d7
  18. Loop:   move.l  d7,d4
  19.     lea Bottle(pc),a4
  20.  
  21.     move.l  d4,d5
  22.     subq    #1,d5
  23.     divu    #10,d5
  24.     move.b  d5,(a4)
  25.     add.b   #"0",(a4)+
  26.     swap    d5
  27.     move.b  d5,(a4)
  28.     add.b   #"0",(a4)
  29.     cmpi    #9,d4
  30.     bls.b   SingleDigit
  31.     subq    #1,a4
  32. SingleDigit:
  33.  
  34.     move.l  d6,d1       ;Show the first bit
  35.     lea Bottle(pc),a0
  36.     move.l  a0,d2
  37.     moveq.l #9,d3
  38.     jsr -$30(a6)    ;Write(d1,d2,d3)dos
  39.  
  40.     cmpi    #2,d7       ;Check for singular (remember, our counter is +1 due to our way of exiting the loop
  41.     beq.b   Singular
  42.     lea Plural(pc),a0
  43.     move.l  d6,d1
  44.     move.l  a0,d2
  45.     moveq.l #1,d3
  46.     jsr -$30(a6)    ;Write(d1,d2,d3)dos
  47. Singular:
  48.     lea EndText(pc),a0
  49.     move.l  d6,d1
  50.     move.l  a0,d2
  51.     moveq.l #21,d3
  52.     jsr -$30(a6)    ;Write(d1,d2,d3)dos
  53.  
  54.     subq.l  #1,d7
  55.     bne.b   Loop
  56.  
  57. ClDos:  move.l  a6,a1
  58.     move.l  4.w,a6
  59.     jsr -$19e(a6)   ;CloseLibrary(a1)exec
  60. Fatal:  moveq.l #0,d0
  61.     rts
  62.  
  63. DosName:
  64.     dc.b    'dos.library',0
  65.     even
  66. Bottle:
  67.     dc.b    'XX bottle'
  68.     even
  69. Plural: dc.b    's',0
  70. EndText:
  71.     dc.b    ' of beer on the wall',$a
  72.     even
  73.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement