6 messages
Open this post in threaded view
|

 Hello folks, I am now in the process of writing my VM translator. I have been able to implement everyting except the portion in the stack test where you push 3 values to the stack and are expected to add them together. Only problem is the simple add i coded in assembly was only good for the simple add test which only push two numbers to the stack at a time. So my question is how do i add more than two numbers with simple add, or do i have to rewrite the simple add into something that has more functionality. Any pointers on this would be helpful. its at this point my stack test is failing.
Open this post in threaded view
|

 Administrator There isn't an "add 3 numbers" stack operation. What you are seeing is an expression being evaluated. 57 & - ((31+53) - 112) push constant 57 push constant 31 push constant 53 add                              adds 32+53 leaves 84 on the stack push constant 112 sub                              subtracts 84-112 leaves -28 on the stack neg                              negates -28 leaves 28 on the stack and                              bitwise And 57 & 28 leaves 24 on the stack Warning, I did the math in my head as I was typing; it may be worng 8-( --Mark
Open this post in threaded view
|

 Ahhhh, I see i was going to go that route but didn't quite know if that was correct. I need to check my sub function to be sure its pulling the values off the stack in the correct order. I found it curious that if i push 7 and then push 6 that it was actually like saying 6-7 instead of 7-6. so in those cases i needed to say D=M-D instead of D=D-M to get the correct result. Is my logic correct on this or did i HACKa solution.
Open this post in threaded view
|

 Administrator pawdwanlearner wrote Ahhhh, I see i was going to go that route but didn't quite know if that was correct. I need to check my sub function to be sure its pulling the values off the stack in the correct order. I found it curious that if i push 7 and then push 6 that it was actually like saying 6-7 instead of 7-6. push a push b sub computes a-b. --Mark