Is there a script/.vm file (that I don't have to write) that will test just the 'call' implementation. I'd rather not jump into that + bootstrapping without knowing that 'call' was implemented correctly.
Ok, I tried that out just copying and pasting. It keeps adding 1 to 123 (at least mine does). At the end, because this function calls no arguments, I try to decrement stack pointer to -1, so it throws an error.
Sound about right?
I haven't considered the case of zero arguments, but once/if you have a fully functioning example (if this isn't already one), i'll tend to that.
The test setup initializes the system pointers as follows
SP = 256
LCL = 300
ARG = 400
THIS = 3000
THAT = 4000
After the call LCL and ARG should be updated and SP should be 263.
The stack should have 2 pushed arguments and a stack frame. Note the the Return Address on the stack is dependent upon your ASM implementation.
Let me know how well this works for you and I'll post it in announcements.
Ok, looks good! It showed the mistakes I made in implementing 'Call'. I was able to fix them and pass the provided test. It truly would've been a pain trying to make those edits while implementing bootstrap (because I'm not sure how easy/hard bootstrap will be until i've completed it, at which point it's too late!).
I think this is the logical way to test things. Now I can confidently move to the next step.
IIRC the poster never replied and I don't recall anyone else asking. I did find the test files in an old directory on my system, but they don't pass with my current VM translator, so I'm guessing that the test was never completed...
Though the halt I think was unnecessary, at least for me. I already have an infinite loop at the end of all my programs, so it basically finishes and renders the last 2 lines of my code (my inf loop) unreachable. No matter, though.
In normal usage, VM code is written by the Jack compiler so all files will always end with a return.
I assume that is why the VM Translator does not spec a halt loop at the end of translation. My philosophy is that test code needs to be belt-and-suspenders, though. That's why there's also a halt loop after the call to Call.fn, which will never return.