## ============================================================ ## fall03exam2q1.s ## ============================================================ ## ============================================================ .section ".text" ## ============================================================ ## ------------------------------------------------------------ ## int clearkeys(struct tree *t) ## ## Set all of the integers in t to 0. ## ## Formal parameter offsets: .equ T, 8 ## ------------------------------------------------------------ .globl clearkeys .type clearkeys,@function clearkeys: pushl %ebp movl %esp, %ebp loop: ## if (t == NULL) goto endloop; cmpl $0, T(%ebp) je endloop ## t->key = 0; movl T(%ebp), %eax movl $0, (%eax) ## clearkeys(t->left); movl T(%ebp), %eax pushl 4(%eax) call clearkeys addl $4, %esp ## t = t->right; movl T(%ebp), %eax movl 8(%eax), %ecx movl %ecx, T(%ebp) ## goto loop; jmp loop endloop: movl %ebp, %esp popl %ebp ret