instructor: Prof. Dr. Peter Thiemann date: 2024-05-07 title: Chapter 5

x = y < z

==>

slt x, y, z
if y < z:
	somethn
else:
    stmt_else

==>

blt y, z, then_branch
j else_branch
sltz d, s1

==>

slt d, s1, zero

Transformation to monadic form

x + (y + z)

==>

t = y + z
x + t
input() if ... else x + z

==>WRONG because input is always executed!

t1 = input()
t2 = x + z
t1 if ... else t2

==>CORRECT

(Begin t1 = input(); t1) if .... else (Begin t2 = x+ z; t2)

Translation of if expressions

exp1 if exp2 else exp3

===> grab new temporary t

if exp2:
	t = exp1
else:
    t = exp3