H04 Midterm Practice

# The parameters are unsigned ints used as a bit vector

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: it work correctly for large ranges. b) Implement the I sSubset function that takes two sets returns whether the first is a subset of the second; that is, all elements of s ub appear in m ain . The parameters are unsigned ints used as a bit vector over the range [0, 31]. Your implementation should only bitwise operators and ==/!=. bool IsSubset(unsigned int sub, unsigned int main) Problem 4: IA32 assembly ( The following IA32 instructions are the disassembly from the Binky function: Binky: push mov sub %ebp %esp, %ebp \$0x10, %esp # function prolog mov imul sub mov 0x8(%ebp), %eax 0x8(%ebp), %eax \$0x7, %eax %eax, -0x4(%ebp) # first line of C code # compiles to these 4 instrs addl \$0x8,0xc(%ebp) # second line of C code mov mov mov add movb -0x4(%ebp), %eax 0xc(%ebp), %edx (%edx, %eax, 4), %eax \$0x3, %eax \$0x41, (%eax) # third line of C code leave ret # function epilog Fill in the body of the Binky function with three lines of C code that compile to the above IA32 instructions. void Binky(int x, char **y) { ___________________________________________________ ___________________________________________________ ___________________________________________________ }...
View Full Document

## This note was uploaded on 02/06/2014 for the course CS 106X taught by Professor Cain,g during the Winter '08 term at Stanford.

Ask a homework question - tutors are online