homework5 - (5) , %eax jmp *%eax .section .rodata .align 4...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 5 Problem 1 Complete the X86 assemble code according to the func_B int func_B(int x, int y) { y = 80 ; switch( x ) { case 72 : x = x + y ; break; case 74 : x = x - y ; case 75 : x = x * y ; break; case 76 : case 79 : if ( x < y ) x = y ; break; default: x += x ; } return y ; } func_B: // Initialize Stack frame (1) (2) subl $4, %esp //store 80 to y movl $80, (3) movl 8(%ebp), %eax subl $72, %eax movl %eax, -4(%ebp) cmpl $7, -4(%ebp) //if > goto default (4) movl -4(%ebp), %edx //goto case
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (5) , %eax jmp *%eax .section .rodata .align 4 .align 4 .L7: .long .L3 (6) .long .L4 (7) .long .L6 .long .L2 .long .L2 .long .L6 .text .L3: movl 12(%ebp), %eax addl %eax, 8(%ebp) //break (8) .L4: movl 12(%ebp), %eax // x = x - y (9) .L5: movl 8(%ebp), %eax imull 12(%ebp), %eax movl %eax, 8(%ebp) jmp .L8 .L6: movl 8(%ebp), %eax cmpl 12(%ebp), %eax (10) movl 12(%ebp), %eax movl %eax, 8(%ebp) jmp .L8 .L2: movl 8(%ebp), %eax addl %eax, 8(%ebp) .L8: //set result as return value (11) leave ret ....
View Full Document

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 2

homework5 - (5) , %eax jmp *%eax .section .rodata .align 4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online