[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How does runtime stack work?
From: |
arnold |
Subject: |
Re: How does runtime stack work? |
Date: |
Fri, 21 May 2021 03:59:27 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> I see a stack is used in gawk. I don't understand what this is used
> for. Could anybody help explain? Thanks.
Out of curiosity, why do you ask?
To briefly answer the question, gawk reads the program and converts
it into an internal form, often called "byte code". The internal form
represents instructions for a "virtual machine" that is stack based.
Operands are pushed onto the stack. Operators pop the operands, do the
operation, and push the result back onto the stack. For example,
x = 3 + 5
would turn into something like:
PUSH 3
PUSH 5
ADD # 3 and 5 are popped off the stack, 8 is pushed on it
STORE x # 8 popped off the stack and stored into 'x'
This is one of several standard mechanisms for implementing programming
language interpreters.
There have been hardware computers that are stack based as well,
although I am not sure which modern architectures, if any, are
stack based.
HTH,
Arnold
- How does runtime stack work?, Peng Yu, 2021/05/20
- Re: How does runtime stack work?,
arnold <=
- Re: How does runtime stack work?, Peng Yu, 2021/05/21
- Re: How does runtime stack work?, david kerns, 2021/05/21
- Re: How does runtime stack work?, arnold, 2021/05/23
- Re: How does runtime stack work?, Wolfgang Laun, 2021/05/23
- Re: How does runtime stack work?, Peng Yu, 2021/05/23
- Re: How does runtime stack work?, arnold, 2021/05/23