Oh, my f(n) word!

Well, we're not going to do your homework for you, but perhaps we can help if you show us what parts of it you can do. This is a case where it would be really helpful to write the comments first, I think!

You don't say, but I suppose this is supposed to be a "C callable" function? Might as well make it so, anyway. A full stack frame, using ebp as a frame pointer, would probably be wise - might help with debugging. Maybe we'll need some local variables, maybe we can get be with non-volitile registers (ebx, esi, edi) for temporary variables... I think you'll need some...

This is sort of an interesting recursive function, in that it needs to call itself twice. Is that going to present any problems? Offer any simplifications? Is this thing going to "blow the stack" under any conditions? (offhand, I don't think so, but I haven't really thought it through).

You say "for n > 2", but you give a value for f(2), so I assume that means "n >= 2", actually(?). That might be an easy place to start. Can you write a function that returns 1 if the passed parameter is less than or equal to 2?

Then for bigger n, we're going to need to...

; multiply n by itself

; subtract 1 from n and call ourselves

; multiply these two values together

; subtract 2 from n and call ourselves

; multiply this result by n-1

; add that result to the result from the first part

; return that (in eax, presumably)

; whew!

... not necessarily in that order... (I notice that we use n-1 twice...). There needs to be more to it than that - after "call ourselves", "clean up stack", for example, and maybe "save to temporary variable" a time or two...

The arithmetic parts are straightforward enough if you're familiar with the instructions. If not, watch out for the implied operands to "mul" - it'll trash edx behind your back (if you've got your back turned). I ASSume that n is going to be a positive integer?... I suppose you'll need a "test caller" - get n (from the user?) and display the result? You know how to do that part?

I'm short on sleep, and that's about as far as I've thought it through... Why don't you show us how far you can get with it, so we can see where you need help, and I'll sleep on it.

Best,

Frank