Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Simple Instruction Machine Programming Language in English

(No the same as SIMPLE on the site.)

Date:07/01/06
Author:Barry Hitchings
URL:n/a
Comments:2
Info:n/a
Score: (3.00 in 79 votes)
[::PROGRAM:99 Bottles of beer
[::IO:
SID::KYB
SOD::TTY
SED::NUL
SSD::NUL
]
[::VARS:
A EQL @1    ; set message pointer
B EQL @3    ; set message pointer
C EQL 99    ; assign variable C
D EQL 1     ; assign variable D
E EQL 0     ; assign variable E
]
C FOR 1     ; for C 99 to 1
D FOR 2     ; for D 1 to 2
RMP A       ; reset message pointer	
PRT C       ; print C
CHR SP      ; write ' '
WRT A       ; write [CR]'Bottle'
C TEQ 1     ; is C = 1
SIT         ; skip instruction if true 
CHR As      ; write 's'
WRT A       ; write ' of beer on the wall'
D TEQ 2     ; is D = 2
<           ; instruction block start
IIT	    ; if true
CHR A,      ; write ','
CHR SP      ; write ' '
HLT         ; halt instruction block
IIF         ; if false
CHR A.      ; write '.'
HLT         ; halt instruction block
>           ; instruction block end
LOP         ; repeat D loop
WRT A       ; write [CR]'Take one down and pass it around, '
E EQL C	    ; E = C		
E SUB 1     ; E - 1
E TEQ 0     ; is E = 0
<           ; instruction block start
IIT         ; if true
WRT B       ; write 'No '
HLT         ; halt instruction block
IIF         ; if false
PRT E       ; print E
CHR SP      ; write ' '
HLT         ; halt instruction block
>           ; instruction block end
WRT A       ; write 'more bottle'
E TEQ 1     ; is E = 1
SIT         ; skip instruction if true
CHR As      ; write 's'
WRT A       ; write ' of beer on the wall.'
LOP         ; repeat C Loop
A MAD 1	    ; A = Message pointer @2
WRT A       ; Write 'Go to the shops....'
END         ; End program 

{::DATA:Message Data
@1:T
$$JBottle$$X of beer on the wall$$X$$JTake one down and pass it around, $$X more bottle$$X of beer
on the wall.$$M
@2:T
$$JNo more bottles of beer on the wall. No more bottles of beer.$$JGo to the shop and buy some more,
99 Bottles of beer on the wall.$$J$$M
@3:T
No $$M
$$@
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Barry Hitchings said on 07/13/06 00:02:25

Barry Hitchings Oops made a mistake...

RMP A ; reset message pointer
PRT C ; print C
CHR SP ; write ' '
WRT A ; write [CR]'Bottle'
C TEQ 1 ; is C = 1

should be

RMP A ; reset message pointer
CHR CR ; write [CR]
PRT C ; print C
CHR SP ; write ' '
WRT A ; write 'Bottle'
C TEQ 1 ; is C = 1

and

@1:T
$$JBottle$$X of beer on the wall$$X$$JTake one down and pass it around, $$X more bottle$$X of beer
on the wall.$$M

should be

@1:T
Bottle$$X of beer on the wall$$X$$JTake one down and pass it around, $$X more bottle$$X of beer
on the wall.$$M

Now it will print correctly... Domo...

>>  Gareth Ollard said on 10/05/06 18:32:17

Gareth Ollard Yo Baz, Get In Contact Dude!
g.ollard@ntlworld.com

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: