Written work 7
Due on October 25th @ 3:00 PM (in class, to Drew, or at Engineering front office)
Not accepted late
Question 1

Convert the following function into 3AC

int g;
int a(int b, int c){
	if (b){
		return 0;
	} else {
		b = b - 1 * c;
	}
	return b;
}

Question 2

Convert the following function into 3AC

int v(int a){
	while (a < 2){
		while (a < 3){
			a++;
		}
		a++;
	}
	return a;
}

Question 3

Convert the following procedure into Drewno Mars. Assume variables are local unless otherwise specified

enter k
       getarg 1, [b]
       [i] = [b]
lbl_1: [t] = [i] LT64 10
       ifz [v] goto lbl_2
       [i] = [i] ADD64 1
       WRITE [i]
       goto lbl_1
lbl_2: nop
leave k

Question 4

Assume a language that allows for pass-by-reference or pass-by-value parameters. What would the 3AC code look like for a pass-by-reference call? Illustrate with an example.