Need to save SP in higher language

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

Need to save SP in higher language

Mikey2520
the add command cannot be implemented because there's no way to let the @ function point to the address specified in SP. However I don't want to initiate an int stored in my Java class to store SP because I have to update it every time for almost any commands while updating the real SP. This method is both time and memory inefficient and very awkward, at least from my perspective. So what should I do?
Reply | Threaded
Open this post in threaded view
|

Re: Need to save SP in higher language

cadet1620
Administrator
Glucocorticoid wrote
there's no way to let the @ function point to the address specified in SP.
The address in SP is just like the data in a variable.  To load variable X into the D register, you would use
    @X
    D=M
To get the address in SP into the A register, do the same thing using SP and A instead of X and D.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Need to save SP in higher language

Mikey2520
Thank you so much!!!!!
You helped me make a breakthrough!
Reply | Threaded
Open this post in threaded view
|

Re: Need to save SP in higher language

Mikey2520
So the mechanism in this is that A is specifies the index of M.