Execute Brain****: Difference between revisions

Content added Content deleted
m (→‎Interpreter: Layout: sometimes alternating line types can be converted to table style)
Line 1,495: Line 1,495:
I = I + 1 !Advance one. The classic.
I = I + 1 !Advance one. The classic.
SELECT CASE(C) !Now decode the instruction.
SELECT CASE(C) !Now decode the instruction.
CASE(">") !Move the data finger one place right.
CASE(">"); D = D + 1 !Move the data finger one place right.
D = D + 1
CASE("<"); D = D - 1 !Move the data finger one place left.
CASE("<") !Move the data finger one place left.
CASE("+"); STORE(D) = CHAR(ICHAR(STORE(D)) + 1) !Add one to the fingered datum.
D = D - 1
CASE("-"); STORE(D) = CHAR(ICHAR(STORE(D)) - 1) !Subtract one.
CASE("+") !Add one to the fingered datum.
CASE("."); WRITE (MSG,1) STORE(D) !Write a character.
STORE(D) = CHAR(ICHAR(STORE(D)) + 1)
CASE(","); READ (KBD,1) STORE(D) !Read a character.
CASE("-") !Subtract one.
CASE("["); IF (ICHAR(STORE(D)).EQ.0) CALL SEEK(+1) !Conditionally, surge forward.
STORE(D) = CHAR(ICHAR(STORE(D)) - 1)
CASE("]"); IF (ICHAR(STORE(D)).NE.0) CALL SEEK(-1) !Conditionally, retreat.
CASE(".") !Write a character.
WRITE (MSG,1) STORE(D)
CASE(",") !Read a character.
READ (KBD,1) STORE(D)
CASE("[") !Conditionally, surge forward.
IF (ICHAR(STORE(D)).EQ.0) CALL SEEK(+1)
CASE("]") !Conditionally, retreat.
IF (ICHAR(STORE(D)).NE.0) CALL SEEK(-1)
CASE DEFAULT !For all others,
CASE DEFAULT !For all others,
!Do nothing.
!Do nothing.
END SELECT !That was simple.
END SELECT !That was simple.
END DO !See what comes next.
END DO !See what comes next.