Confusion with debugging!

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Confusion with debugging!

harshchikorde1234@gmail.com
I have successfully done with my SimpleFunction VM code but I am getting an error in the 'NestedCall" test and I don't know where exactly I am going wrong! I am tired at this point(it's been three days) about how exactly should I debug the error which is "Comparision failure at line 2". I tried various methods suggested in the forum but it's not working, my Output is as below:

| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] |
|    362 |    356 |    351 |   4001 |   5000 |     -1 |     -1 |
 
which must be as shown below to be correct:

| RAM[0] | RAM[1] | RAM[2] | RAM[3] | RAM[4] | RAM[5] | RAM[6] |
|    261 |    261 |    256 |   4000 |   5000 |    135 |    246 |

Please suggest to me what I need to do!
Firstly I thought my Call and return code must be having an error but it has been successfully executed in the SimpleFunction VM code! which means I am not wrong here, then I tried to run parallelly my generated assembly code line by line(with some markers) and VM code in VM Emulator, but since it is very long I am unable to do so.

Does my existing VM code need any modifications after SimpleFunction test?

Reply | Threaded
Open this post in threaded view
|

Re: Confusion with debugging!

WBahn
Administrator
Just because SimpleFunction worked does not mean that your VM code for calling functions and returning from this is correct, just that the issue didn't manifest itself in such a limited test. The NestedCall is a much more thorough test. You are probably corrupting the call stack of the prior function call when the second call is made (or returned from).

Notice that your Stack Pointer ends up at 362, which is WAY out of line with anything that would be reasonable. So you might step through the code and see where R0 just changed so significantly.