Consider the Java program shown in Figure 10.8. Assume that this is to be compiled to native

Question:

Consider the Java program shown in Figure 10.8. Assume that this is to be compiled to native code on a machine with 4-byte addresses.

Figure 10.8

interface Pingable { public void ping (); 1. 2. 3. 4. class Counter implements Pingable { 5. int count = 0; %3! 6. public void ping() { 7. ++count; 8. 9. public int val () { 10. return count; 11. 12. 13. public class Ping ( 14. public static void

(a) Draw a picture of the layout in memory of the object created at line 15. Show all virtual function tables.

(b) Give assembly-level pseudocode for the call to c.val at line 19. You may assume that the address of c is in register r1 immediately before the call, and that this same register should be used to pass the hidden this parameter. You may ignore the need to save and restore registers, and don’t worry about where to put the return value.

(c) Give assembly-level pseudocode for the call to c.ping at line 17. Again, assume that the address of c is in register r1, that this is the same register that should be used to pass this, and that you don’t need to save or restore any registers.

(d) Give assembly-level pseudocode for the body ofmethod Counter.ping (again ignoring register save/restore).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: