Question: 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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Translating the given BL BugsWorld Language programs into their executable form involves converting highlevel instructions into a sequence of bytecode instructions that the BugsWorld Virtual Machine c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!