Advertisement
Guest User

99 Bottles.s

a guest
Aug 26th, 2018
137
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
  41.                 ;is +1 due to our use of exiting the loop
  42.     beq.b   Singular
  43.     lea Plural(pc),a0
  44.     move.l  d6,d1
  45.     move.l  a0,d2
  46.     moveq.l #1,d3
  47.     jsr -$30(a6)    ;Write(d1,d2,d3)dos
  48. Singular:
  49.     lea EndText(pc),a0
  50.     move.l  d6,d1
  51.     move.l  a0,d2
  52.     moveq.l #21,d3
  53.     jsr -$30(a6)    ;Write(d1,d2,d3)dos
  54.  
  55.     subq.l  #1,d7
  56.     bne.b   Loop
  57.  
  58. ClDos:  move.l  a6,a1
  59.     move.l  4.w,a6
  60.     jsr -$19e(a6)   ;CloseLibrary(a1)exec
  61. Fatal:  moveq.l #0,d0
  62.     rts
  63.  
  64. DosName:
  65.     dc.b    'dos.library',0
  66.     even
  67. Bottle:
  68.     dc.b    'XX bottle'
  69.     even
  70. Plural: dc.b    's',0
  71. EndText:
  72.     dc.b    ' of beer on the wall',$a
  73.     even
  74.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement