push constant

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

push constant

bikal
The book in chapter 7 says the index is nonnegative integer. Does this mean that can only push positive integers as constant in the VM?
Reply | Threaded
Open this post in threaded view
|

Re: push constant

ashort
This post was updated on .
the vm can only push integers that are 0 or positive (>=0), meaning all non-negative integers.

if you're wondering how to get a negative integer at the top of the stack,  I bet you can figure it out, and if not, you will soon...
Reply | Threaded
Open this post in threaded view
|

Re: push constant

WBahn
Administrator
In reply to this post by bikal
Yes. And that's because this mirrors the restriction on the A-type instructions in the assembly language.

It would certainly be possible to devise a VM language that allows for negative constants, but implementing the translator because more difficult, but still very possible.