I have an Intel build assignment. I need to write a calculator that uses 2 stacks. For example, I have an expression like 23 + 4/2 ^ 4 $. So $ indicates the end of the expression. I will do this to have two stacks, one for numbers, one for operators, and push and pop them according to the priority of the operator.
I need how I can use 2 stacks for two different purposes at the same time. As long as I know, the esp register indicates the place for variables on the stack to pop up last or hit new. But if I have only one esp register, how can I have two stacks?
Thanks in advance...
, Dijkstra.
, , .
, . - . , , , , , .
, ; ; , - .
, , . , , , , .
, , . http://epaperpress.com/oper/index.html
, . , .
: : , , , , ( , , ). , , , . , , , , , . ( , , .)
, L, L, 2L .ESP 2L, ESP , ESP + L ( , L beacause, L).. , infix . .
: - .2 , EBX, ECX, ,ESP, ESP + L. , , ESP EBX ECX , , push pop ESP, , ESP, , . , pop/push, EBX/ECX ESP.
, :
mov ecx,256 L1: call ReadInt push eax ;push the integer to where esp=1 points add esp,ecx ;esp=1+256=257, now esp points to 257. call ReadChar ;read operand cmp al,endChar ;compare with end sign=$ je next push al ;push operand to where esp=257 points sub esp,ecx ;esp=257-256=1, now esp is in the original position loop L1 next: ...
, .
By the way, I have "1> .. \ main.asm (46): error A2149: byte register cannot be the first operand" error for (push al)? what is the question?
thanks...