hmwk1_probSet_ch

hmwk1_probSet_ch - #include <stdlib.h> extern compare...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COMPE 271 - FALL 2011 Homework 1 Given the following function compare that accepts two integer arguments: int compare ( int a, int b) { if ( a > b ) return (1); if (a < b) return (-1); if (a == b ) return (0); } .global _compare _compare: pushl %ebp movl %esp , %ebp movl %ebp ,&esp popl %ebp ret _____________________________________________ The main function calling the function compare is given below as example. #include <stdio.h>
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include <stdlib.h> extern compare (); int main ( void ) { int a, b; a=10; b=7; if (compare(a,b) == 0) { puts ( "They are equal" ); } if (compare(a,b) > 0) { puts ( "a is greater than b " ); } if (compare(a,b) < 0) { puts( "a is smaller than b " ); } The function is called as given in the following program. Write the function compare in assembly language starting With the skeleton code given on the right....
View Full Document

This note was uploaded on 06/07/2011 for the course COMPE 271 taught by Professor Staff during the Spring '08 term at San Diego State.

Ask a homework question - tutors are online