Question: Design a TM to execute programs written in a simplified assembly - like language. The attached picture is as far as I have gotten in
Design a TM to execute programs written in a simplified assemblylike language. The attached picture is as far as I have gotten in the simulator. I think I have L Mx and My but I am not quite sure. I need someone to check it and then help me figure out A I have had it described to me but I just dont get it and need to see it The input in the simulator is L:Mx:L:My:A:Mx:L:My:A: and the output should be
There are just four instructions: L Mx My and A operating on three registers x y and z each
holding a nonnegative integer.
L instructions load a certain constant number, represented in binary, into register z
For example, the instruction L loads the integer represented by the bits
into z Other bit strings can be specified. The number of bits may be
arbitrary, but you may assume it is the same for all load instructions in the program. For
instance, if the first instruction is L then all remaining L instructions
will be followed by exactly bits.
Mx and My instructions move the value from z into x or y respectively. Actually its
more like copy since the value in z is not erased, but move is the traditional assembly
language name for this instruction.
A instructions add the values in registers x and y and store the result in register z If
the result overflows, the new most significant is simply omitted; ie the result is taken
mod k where k is the number of bits specified in the first load instruction. For example,
adding to results in and adding
to results in This might sound difficult, but actually
the straightforward way to implement addition will automatically achieve this.
If an instruction needs to read a register add must read x and y and move must read z
then you may assume that register has already had a value written to it
The input will be a followed by a list of instructions, each followed by a : such as
L:Mx:L:My:A:Mx:L:My:A:
The above program does the following
load the value into z and then move it into x
load the value into z and then move it into y
add x and y and store the result in z
move the value in z into x
load the value into z and move it into y
add x and y and store the result in z
Your TM should produce a string output equal to the value of register z represented as a
binary string after the last instruction executes. So the correct output above is
Furthermore, your TM should halt in the accept state.
You may assume only input strings matching the above description will be supplied. Your
TM does not have to detect syntax errors in the assembly language program.
It helps to use one worktape per register, and to write special marker symbols at the
start of each of them to help identify when the tape head is scanning the leftmost tape cell.
It is also recommended to use wildcards in the transition rules.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
