### Abstract

The evaluation of arithmetic expressions on both register-oriented and stack-oriented machines can be studied using the same model because registers can be treated as a stack during the evaluation of expression trees, without loss in code efficiency. The machine model in this paper has a hardware stack in which all computations take place. Register-register and register-memory instructions are modeled by considering four possible instructions for each binary operator, depending on whether one or two operands are taken from the stack and on whether the left or the right operand is on top of the stack. There is a cost associated with each operation code, as well as costs for accessing a value in a register or in memory. The minimum cost of computing an expression tree is used to compare machines. As part of the framework that allows the comparisons to be performed, a parameterized algorithm for determining the number of stores that must occur in an optimal computation is developed. This algorithm forms the basis of an optimal code generation algorithm.

Original language | English (US) |
---|---|

Pages (from-to) | 457-478 |

Number of pages | 22 |

Journal | Journal of the ACM |

Volume | 30 |

Issue number | 3 |

DOIs | |

Publication status | Published - Jul 1983 |

Externally published | Yes |

### Fingerprint

### ASJC Scopus subject areas

- Computational Theory and Mathematics
- Computer Graphics and Computer-Aided Design
- Hardware and Architecture
- Information Systems
- Software
- Theoretical Computer Science

### Cite this

*Journal of the ACM*,

*30*(3), 457-478. https://doi.org/10.1145/2402.322388