Fix
sub to mean . If the depth-minimizing order evaluates the right operand before the left operand , the stack ends in , so ordinary sub would compute the wrong sign. Two possible instruction set architecture extensions are:- Add
swap, with . After computing and then , useswap; subto obtain . One general zero-address instruction handles every noncommutative binary operation and is useful elsewhere, but each reversed evaluation needs an extra instruction and extra execution time. It can be implemented without an additional operand stack slot. - Add reverse-operand variants, such as
rsubwith , and analogously reverse division and other required operations. After computing and then , a singlersubobtains . This avoids the extra executedswap, but requires more opcodes and decoder support, usually one reverse form for each affected operation.
Articles by others on the same topic
There are currently no matching articles.