Maesltrom wrote
Hi fellows! I have some questions that are freezing me in this chapter.
1- In file Stacktest.comp, TRUE values are threaten as -1 (minus 1) and FALSE as 0 the opposite from book
The book does say that true is -1 and false is 0. There have been several other people who have also been confused by this. I think the way it is written is problematic for non-native English speakers:
"The VM represents true and false as -1 (minus one, 0xFFFF)
and 0 (zero, 0x0000), respectively."
It would be better, I think, to write it as:
"The VM represents true as -1 (minus one, 0xFFFF), and
false as 0 (zero, 0x0000)."
2- I wrote a code to AND and OR work with -1 and 0 constants so i can't understand this part of code:
"push constant 56
push constant 31
push constant 53
add //31+53=84
push constant 112
sub //84-112=-28
neg //neg -28 = 28
and //I don't understand this AND operation here
"
Please, help me
"and" is binary and of 28 with 56 which is already on the stack.
followed by "push 80; or" which does a binary or of the previous result with 80.
--Mark