Monday, March 22, 2010

Here is 99 bottles of beer in RESOL.

C 99 BOTTLES IN RESOL
001 DATA 000001
DATA 003,9876543210
DATA 004,9876543210
DATA 005,99
CALL 007,7
CALL 10002
CALL 002
STOP
002 DATA 000001
DATA 002
DATA 002,10001
DATA 001,10001
DATA 10001
CONTINUE 002
003 DATA 000001
004 DATA 000001
005 DATA 000002
C DECREMENT COUNTER
006 IF 003,0
DATA 003,9876543210
IF 003,0
DATA 004
DATA 003
DATA 005,004
DATA 005,003
DATA 005
CONTINUE 006
007 DATA 000001
CALL 100,005
CALL 008
CALL 10000,0200 0415 0406 0200 0402 0405 0405 0502
+ 0200 0415 0414 0200 0504 0408 0405
+ 0200 0507 0401 0412 0412 0212 0200
CALL 100,005
CALL 008
CALL 10000,0200 0415 0406 0200 0402 0405 0405 0502 0214 0010
CALL 002
IF 00,005
CONTINUE 007,009
CALL 10000,0504 0401 0411 0405 0200 0415 0414 0405
+ 0200 0404 0415 0507 0414 0200 0401 0414 0404
+ 0200 0500 0401 0503 0503 0200 0409 0504
+ 0200 0401 0502 0415 0505 0414 0404 0212 0200
CALL 006
CALL 100,005
CALL 008
CALL 10000,0200 0415 0406 0200 0402 0405 0405 0502
+ 0200 0415 0414 0200 0504 0408 0405
+ 0200 0507 0401 0412 0412 0214 0010 0010
CALL 002
CONTINUE 007
C BOTTLE(S)
008 CALL 10000,0200 0402 0415 0504 0504 0412 0405
IF 01,005
CONTINUE 008
CALL 10000,0503
CONTINUE 008
009 CALL 10000,0407 0415 0200 0504 0415 0200 0504 0408 0405
+ 0200 0503 0504 0415 0502 0405 0200 0401 0414 0404
+ 0200 0402 0505 0509 0200 0503 0415 0413 0405
+ 0200 0413 0415 0502 0405 0212 0200 0309 0309
+ 0200 0402 0415 0504 0504 0412 0405 0503
+ 0200 0415 0406 0200 0402 0405 0405 0502
+ 0200 0415 0414 0200 0504 0408 0405
+ 0200 0507 0401 0412 0412 0214 0010
DATA 007
CONTINUE 007
C OUTPUT PASSED IN COUNT OR "NO MORE" WHEN COUNT IS 00
100 DATA 000001
IF 100,0
CALL 101
CONTINUE 100,103
101 DATA 100
IF 100,0
CALL 10000,0414041502000413041505020405
IF 100,0
CONTINUE 100,102
CALL 104
102 DATA 100
CONTINUE 101
103 CALL 104
DATA 100
CALL 104
DATA 100
CONTINUE 100
104 IF 100,0
CALL 10000,0300
IF 100,1
CALL 10000,0301
IF 100,2
CALL 10000,0302
IF 100,3
CALL 10000,0303
IF 100,4
CALL 10000,0304
IF 100,5
CALL 10000,0305
IF 100,6
CALL 10000,0306
IF 100,7
CALL 10000,0307
IF 100,8
CALL 10000,0308
IF 100,9
CALL 10000,0309
CONTINUE 104
C THIS IS A LIBRARY THAT CONVERTS 4-BIT ITEMS ENQUEUED INTO 10000 AS 2 DIGITS
C INTO 3-BIT ITEMS IN 1 DIGIT THAT ARE AVAILABLE AT 10001.
C CALL 10000 TO PROCESS ITEMS FROM 10000 INTO 10001.
C CALL 10002 TO FLUSH THE FINAL DANGLING BITS (0-2 BITS).
C
C IF 000002 IS A DATA STATEMENT, CALLING 10000 WILL DEQUEUE FROM IT. BEST
C NOT TO HAVE 000002 AS A LABEL (WHICH WOULD REQUIRE A CONTINUATION LINE).
C
10000 DATA 000002
IF 10003,11000
CALL 10100
IF 10003,11001
CALL 10110
IF 10003,11002
CALL 10120
DATA 10003
DATA 10000
CONTINUE 10000
10001 DATA 1
C
C FLUSH THE FINAL DANGLING BITS
10002 IF 10003,11000
CONTINUE 10002
DATA 10001,10004
DATA 10004
C REINITIALIZE 10003 TO 012
IF 10003,11001
DATA 10003
DATA 10003
DATA 10003,012
CONTINUE 10002
C
C 10003 HOLDS THE NUMBER OF DANGLING BITS
10003 DATA 1,012
C 10004 HOLDS THE VALUE OF THE DANGLING BITS
10004 DATA 1
C
C NO DANGLING BITS FROM BEFORE. LEAVES 1 DANGLING BIT FOR NEXT ITEM.
10100 IF 10000,12000
DATA 10001,11000
IF 10000,12000
DATA 10004,11000
IF 10000,12001
DATA 10001,11000
IF 10000,12001
DATA 10004,11004
IF 10000,12002
DATA 10001,11001
IF 10000,12002
DATA 10004,11000
IF 10000,12003
DATA 10001,11001
IF 10000,12003
DATA 10004,11004
IF 10000,12004
DATA 10001,11002
IF 10000,12004
DATA 10004,11000
IF 10000,12005
DATA 10001,11002
IF 10000,12005
DATA 10004,11004
IF 10000,12006
DATA 10001,11003
IF 10000,12006
DATA 10004,11000
IF 10000,12007
DATA 10001,11003
IF 10000,12007
DATA 10004,11004
IF 10000,12008
DATA 10001,11004
IF 10000,12008
DATA 10004,11000
IF 10000,12009
DATA 10001,11004
IF 10000,12009
DATA 10004,11004
IF 10000,12010
DATA 10001,11005
IF 10000,12010
DATA 10004,11000
IF 10000,12011
DATA 10001,11005
IF 10000,12011
DATA 10004,11004
IF 10000,12012
DATA 10001,11006
IF 10000,12012
DATA 10004,11000
IF 10000,12013
DATA 10001,11006
IF 10000,12013
DATA 10004,11004
IF 10000,12014
DATA 10001,11007
IF 10000,12014
DATA 10004,11000
IF 10000,12015
DATA 10001,11007
IF 10000,12015
DATA 10004,11004
CONTINUE 10100
C
C 1 DANGLING BIT FROM BEFORE. LEAVES 2 DANGLING BITS FOR NEXT ITEM.
10110 IF 10004,11000
CALL 10111
IF 10004,11004
CALL 10112
DATA 10004
CONTINUE 10110
C DANGLING 0 FROM BEFORE
10111 IF 10000,12000
DATA 10001,11000
IF 10000,12000
DATA 10004,11000
IF 10000,12001
DATA 10001,11000
IF 10000,12001
DATA 10004,11002
IF 10000,12002
DATA 10001,11000
IF 10000,12002
DATA 10004,11004
IF 10000,12003
DATA 10001,11000
IF 10000,12003
DATA 10004,11006
IF 10000,12004
DATA 10001,11001
IF 10000,12004
DATA 10004,11000
IF 10000,12005
DATA 10001,11001
IF 10000,12005
DATA 10004,11002
IF 10000,12006
DATA 10001,11001
IF 10000,12006
DATA 10004,11004
IF 10000,12007
DATA 10001,11001
IF 10000,12007
DATA 10004,11006
IF 10000,12008
DATA 10001,11002
IF 10000,12008
DATA 10004,11000
IF 10000,12009
DATA 10001,11002
IF 10000,12009
DATA 10004,11002
IF 10000,12010
DATA 10001,11002
IF 10000,12010
DATA 10004,11004
IF 10000,12011
DATA 10001,11002
IF 10000,12011
DATA 10004,11006
IF 10000,12012
DATA 10001,11003
IF 10000,12012
DATA 10004,11000
IF 10000,12013
DATA 10001,11003
IF 10000,12013
DATA 10004,11002
IF 10000,12014
DATA 10001,11003
IF 10000,12014
DATA 10004,11004
IF 10000,12015
DATA 10001,11003
IF 10000,12015
DATA 10004,11006
CONTINUE 10111
C DANGLING 1 FROM BEFORE
10112 IF 10000,12000
DATA 10001,11004
IF 10000,12000
DATA 10004,11000
IF 10000,12001
DATA 10001,11004
IF 10000,12001
DATA 10004,11002
IF 10000,12002
DATA 10001,11004
IF 10000,12002
DATA 10004,11004
IF 10000,12003
DATA 10001,11004
IF 10000,12003
DATA 10004,11006
IF 10000,12004
DATA 10001,11005
IF 10000,12004
DATA 10004,11000
IF 10000,12005
DATA 10001,11005
IF 10000,12005
DATA 10004,11002
IF 10000,12006
DATA 10001,11005
IF 10000,12006
DATA 10004,11004
IF 10000,12007
DATA 10001,11005
IF 10000,12007
DATA 10004,11006
IF 10000,12008
DATA 10001,11006
IF 10000,12008
DATA 10004,11000
IF 10000,12009
DATA 10001,11006
IF 10000,12009
DATA 10004,11002
IF 10000,12010
DATA 10001,11006
IF 10000,12010
DATA 10004,11004
IF 10000,12011
DATA 10001,11006
IF 10000,12011
DATA 10004,11006
IF 10000,12012
DATA 10001,11007
IF 10000,12012
DATA 10004,11000
IF 10000,12013
DATA 10001,11007
IF 10000,12013
DATA 10004,11002
IF 10000,12014
DATA 10001,11007
IF 10000,12014
DATA 10004,11004
IF 10000,12015
DATA 10001,11007
IF 10000,12015
DATA 10004,11006
CONTINUE 10112
C
C 2 DANGLING BITS FROM BEFORE. LEAVES NO DANGLING BITS FOR NEXT ITEM.
10120 IF 10004,11000
CALL 10121
IF 10004,11002
CALL 10122
IF 10004,11004
CALL 10123
IF 10004,11006
CALL 10124
DATA 10003,13012
DATA 10004
IF 10000,12000
DATA 10001,11000
IF 10000,12001
DATA 10001,11001
IF 10000,12002
DATA 10001,11002
IF 10000,12003
DATA 10001,11003
IF 10000,12004
DATA 10001,11004
IF 10000,12005
DATA 10001,11005
IF 10000,12006
DATA 10001,11006
IF 10000,12007
DATA 10001,11007
IF 10000,12008
DATA 10001,11000
IF 10000,12009
DATA 10001,11001
IF 10000,12010
DATA 10001,11002
IF 10000,12011
DATA 10001,11003
IF 10000,12012
DATA 10001,11004
IF 10000,12013
DATA 10001,11005
IF 10000,12014
DATA 10001,11006
IF 10000,12015
DATA 10001,11007
CONTINUE 10120
C DANGLING 00 FROM BEFORE
10121 IF 10000,12000
DATA 10001,11000
IF 10000,12001
DATA 10001,11000
IF 10000,12002
DATA 10001,11000
IF 10000,12003
DATA 10001,11000
IF 10000,12004
DATA 10001,11000
IF 10000,12005
DATA 10001,11000
IF 10000,12006
DATA 10001,11000
IF 10000,12007
DATA 10001,11000
IF 10000,12008
DATA 10001,11001
IF 10000,12009
DATA 10001,11001
IF 10000,12010
DATA 10001,11001
IF 10000,12011
DATA 10001,11001
IF 10000,12012
DATA 10001,11001
IF 10000,12013
DATA 10001,11001
IF 10000,12014
DATA 10001,11001
IF 10000,12015
DATA 10001,11001
CONTINUE 10121
C DANGLING 01 FROM BEFORE
10122 IF 10000,12000
DATA 10001,11002
IF 10000,12001
DATA 10001,11002
IF 10000,12002
DATA 10001,11002
IF 10000,12003
DATA 10001,11002
IF 10000,12004
DATA 10001,11002
IF 10000,12005
DATA 10001,11002
IF 10000,12006
DATA 10001,11002
IF 10000,12007
DATA 10001,11002
IF 10000,12008
DATA 10001,11003
IF 10000,12009
DATA 10001,11003
IF 10000,12010
DATA 10001,11003
IF 10000,12011
DATA 10001,11003
IF 10000,12012
DATA 10001,11003
IF 10000,12013
DATA 10001,11003
IF 10000,12014
DATA 10001,11003
IF 10000,12015
DATA 10001,11003
CONTINUE 10122
C DANGLING 10 FROM BEFORE
10123 IF 10000,12000
DATA 10001,11004
IF 10000,12001
DATA 10001,11004
IF 10000,12002
DATA 10001,11004
IF 10000,12003
DATA 10001,11004
IF 10000,12004
DATA 10001,11004
IF 10000,12005
DATA 10001,11004
IF 10000,12006
DATA 10001,11004
IF 10000,12007
DATA 10001,11004
IF 10000,12008
DATA 10001,11005
IF 10000,12009
DATA 10001,11005
IF 10000,12010
DATA 10001,11005
IF 10000,12011
DATA 10001,11005
IF 10000,12012
DATA 10001,11005
IF 10000,12013
DATA 10001,11005
IF 10000,12014
DATA 10001,11005
IF 10000,12015
DATA 10001,11005
CONTINUE 10123
C DANGLING 11 FROM BEFORE
10124 IF 10000,12000
DATA 10001,11006
IF 10000,12001
DATA 10001,11006
IF 10000,12002
DATA 10001,11006
IF 10000,12003
DATA 10001,11006
IF 10000,12004
DATA 10001,11006
IF 10000,12005
DATA 10001,11006
IF 10000,12006
DATA 10001,11006
IF 10000,12007
DATA 10001,11006
IF 10000,12008
DATA 10001,11007
IF 10000,12009
DATA 10001,11007
IF 10000,12010
DATA 10001,11007
IF 10000,12011
DATA 10001,11007
IF 10000,12012
DATA 10001,11007
IF 10000,12013
DATA 10001,11007
IF 10000,12014
DATA 10001,11007
IF 10000,12015
DATA 10001,11007
CONTINUE 10124
C
C CONSTANTS
11000 DATA 1,0
11001 DATA 1,1
11002 DATA 1,2
11003 DATA 1,3
11004 DATA 1,4
11005 DATA 1,5
11006 DATA 1,6
11007 DATA 1,7
12000 DATA 2,00
12001 DATA 2,01
12002 DATA 2,02
12003 DATA 2,03
12004 DATA 2,04
12005 DATA 2,05
12006 DATA 2,06
12007 DATA 2,07
12008 DATA 2,08
12009 DATA 2,09
12010 DATA 2,10
12011 DATA 2,11
12012 DATA 2,12
12013 DATA 2,13
12014 DATA 2,14
12015 DATA 2,15
13012 DATA 3,012

No comments:

Post a Comment