KSP Task 3Implement the new instructions(see attached file) for testing numbers (eq, ne, lt, le, gt, ge) that represent the numeric comparisons (==, !=, , >=). The effects on the stack can be seen...

KSP Task 3Implement the new instructions(see attached file) for testing numbers (eq, ne, lt, le, gt, ge) that represent the numeric comparisons (==, !=, <,><=,>, >=). The effects on the stack can be seen here(see attachment). The result of a comparison, a Boolean value, is represented by the integer 0 for "false" or 1 for "true". Of course there is an assembler(see attachment) which can also assemble the new instructions.
2. take the unconditional jump as well as the two conditional jumps ("branch on false" and "branch on true"). The immediate value in these instructions specifies the jump target. The conditional jumps check the top stack element to decide whether to jump. If there is no jump, the next instruction is executed. The effects on the stack can be seen again here(see attachment). The assembler has a new command line option "--map"; what can I do with it?
Now comes the first somewhat bigger task: an interactive debugger for your VM. The instructions become more complicated, the programs to be executed more extensive - one wishes to learn more about the inner state of the VM, especially when errors occur.
a) In contrast to earlier tasks, the program should no longer be automatically listed after loading, but simply executed. But if you start the VM with the command line switch --debug, the interactive debugger should report after loading the program and wait for commands, which it then executes.
b) Write a short but exact specification of which commands your debugger should understand. As a small hint for those who can't imagine much of such a part: What do you want to be able to track or even influence the progress of the program? Let's just load this example program 1(see attachment) Of course you can also try this in practice by changing some instruction (e.g. the second "brf") into another instruction (e.g. "brt"), or even better: have it changed by your other group member without knowing what happened. What tools do I need to locate the bug? As a minimum the commands "Display stack", "Display static data", "Program lists", "Execute next command", "Continue without stopping" and "Exit VM" must be included. It is also very useful to "set a breakpoint" (if the program passes it later during execution, it stops and the debugger takes control). Of course you can get some suggestions from the reference implementation as well:njvm
c) Now implement the debugger commands you have provided. Use sample program 1(see attachment) You will probably think of some improvements - then go back to b).
Apr 23, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here