can't find the bug in my asm file. please help

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

can't find the bug in my asm file. please help

thedumbone
This is basicTest.cmp file:

|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] |
|    472 |     10 |     21 |     22 |     36 |     42 |     45 |    510 |

and this is my basicTest.out file:

|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] |
|     10 |     10 |     21 |     22 |     36 |     42 |     45 |    510 |

-----------------------------------------------

this is pointTest.cmp:

|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
|   6084 |   3030 |   3040 |     32 |     46 |

and this is pointTest.out:

|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
|   3030 |   3030 |   3040 |     32 |     46 |

--------------------------------------------------

I cross checked my vm to assembly translation in chatgpt and it says that everything is fine with the translation. When i compare the files in cpu emulator, the code runs till the end and says that error is at line 2. but shouldn't it stop where the error occurred? And sometimes the code runs even after the point where it should stop (the ticktock count in the tst script) and it very buggy in general (if that is causing any problem, in case):


I am first loading the test script in the cpu emulator and then loading the asm file. am i doing it right?

I can't find the problem in my asm file as well. please help me find the bug🙏
Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

WBahn
Administrator
In both cases, it appears that your issue is with RAM[256] and, since the screen capture says that it is failing at line 2, it is the very first test (since the first line is a header).

So walk through your code and execute it manually and see if you come up with the same result for RAM[256] that your ASM code is producing. Also, make sure that you agree that the code in the compare file is correct.

Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

thedumbone
these are the first three commands. but they look okay to me:

// push constant 10
@10
D=A
@SP
A=M
M=D
@SP
M=M+1
// pop local 0
@LCL
D=M
@0
D=D+A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
// push constant 21
@21
D=A
@SP
A=M
M=D
@SP
M=M+1
Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

pm100
In reply to this post by thedumbone
couple of things

1 no you dont need to load the .asm file , the test script does that for you, look at the first line of it 'load Pointertest.asm'. Just load the script and hit run

2. The error message meaning that the comparison failed on line 2 to the .cmp file. The script runs the test to the end, captures some ram locations into a .out file and compare the 2. The error says line 2 of .cmp and .out are different. And you can see that they are. It does not mean that the error is at line 2 on the asm file

Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

pm100
screen shots show Pointertest, this code shows basictest. Which is it?
Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

thedumbone
SS is just for reference. the code is from basic test. i cross checked with chatgpt and other github repo code. i can't understand what is the issue
Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

pm100
In reply to this post by pm100
fine, but you understood my explanation of the error message tho? It means line 2 of the cmp file, not line 2 of the asm file.


To debug follow what happens to one of the tested ram locations (256) it should be 472 at the end, but your code leaves it with 10

Simple step through the code watching the changes to that location.

Hard to debug from here without seeing the asm file
Reply | Threaded
Open this post in threaded view
|

Re: can't find the bug in my asm file. please help

thedumbone
Thank you. I found the bug