1. Engineering
2. Computer Science
3. translate the following four bl programs into their executable form...

# Question: translate the following four bl programs into their executable form...

###### Question details

Translate the following four BL programs into their executable form in the tables next to each example using the code generation "patterns" discussed in class(especially slides 30-47).

http://web.cse.ohio-state.edu/software/2231/web-sw2/extras/slides/28.Code-Generation.pdf

Use only the primitives: MOVE, TURNLEFT, TURNRIGHT, INFECT, SKIP, and HALT; unconditional jump: JUMP; and the conditional jumps: JUMP_IF_NOT_NEXT_IS_EMPTY, JUMP_IF_NOT_NEXT_IS_NOT_EMPTY, etc.) Note that the tables may be bigger than the actual length of the generated code.

PROGRAM Example1 IS
BEGIN
IF next-is-wall THEN
turnright
turnright
infect
END IF
END Example1

 0 1 2 3 4 5 6 7 8 9 10
PROGRAM Example2 IS
BEGIN
IF next-is-wall THEN
turnright
turnright
infect
ELSE
infect
move
END IF
END Example2

 0 1 2 3 4 5 6 7 8 9 10
PROGRAM Example3 IS
BEGIN
WHILE next-is-not-empty DO
IF next-is-wall THEN
turnright
turnright
infect
ELSE
infect
move
END IF
END WHILE
END Example3

 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
PROGRAM Example4 IS

INSTRUCTION TurnBackAndInfect IS
turnright
turnright
IF next-is-enemy THEN
infect
END IF
END TurnBackAndInfect

BEGIN
WHILE true DO
TurnBackAndInfect
END WHILE
END Example4

 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15