I am coding in 8086 assembler and I have ran into an interesting question. The topic is to evaluate parentheses. If this was a question in Java or C, I would simply define two stacks - one for numbers, and another for operands. Can I do something similar in Assembly?
As far as I know, the Stack is defined in the last memory cells of the data segment. If I define another Data Segment, would I have another usable stack?
Another info: I don't know the input size in the beginning and I am supposed to make the program as efficient as possible.
Thanks!
This is true if you're developing a .COM style program where all the segment registers have the same value and where DOS placed the stackpointer at the high end of this 64KB memory.
There's no need to change the Data Segment to have another stack. Change the SS:SP register pair and start using the newly defined stack.
The stack extends downwards starting at
SP. So if you had SP=4096 then the stack would be 4096 bytes. (not counting wraparound which would probably be wrong anyway)