If your teacher really gave you that "DoIt", drop the course - it won't even assemble as presented! If you screwed it up yourself, okay you're allowed to make mistakes. Nobody was born knowing this stuff.
I've been out of school so long I wasn't sure I remembered Fibonacci. I guess I do. The first two numbers in the series are 1, and after that each number is the sum of the previous two. Sounds like the "add" instruction might be useful.
Recursion is a tough assignment for beginners! (recursion error: see recursion error) It just means that a routine calls itself. Of course, this means that you have to manage the stack correctly, and you have to know when to stop!
"main()" is in "driver.c" and just calls "asm_main". You probably don't want to mess with it. "asm_main" is where your program starts. Since you've got as far as a prompt, I suppose the first thing is to display it.
mov eax, output
call print_int
But wait! At the end of "asm_main", you're going to want to return (the instruction is "ret", not "return"). You may want to set up a stack frame (although there are no parameters on the stack and we don't need any local variables) and save registers C expects to be preserved...
enter 0, 0
pusha
; your code
popa
mov eax, 0 ; return zero
leave
ret
I consider that overkill, and I like to be able to return a non-zero value, but that seems to be what the examples show, so that's probably the way you're "supposed" to do it.
Where were we? Oh yeah, after asking for a number, and providing a place to put it, I suppose the next thing is...
call read_int
mov [userInput], eax
At this point, you might be ready to start thinking about calling "DoIt". If you fix your "DoIt" so it works at all, it'll count down from the number you passed it. That's a start, but it doesn't calculate any Fibonacci numbers. There's probably a better way to do it, but the naive approach I came up with was to pass our function the last two numbers in the series (we know we want to start with 1, 1) along with the remaining count. This requires some changes to "stack management". Where your "DoIt" does:
push ecx
call DoIt
pop ecx
The "pop ecx" is just to "clean up the stack" (remove the parameters you pushed). You could do "pop ecx" three times, but I prefer to do it like this:
push (next to last number in series)
push (last number in series)
push ecx
call DoIt
add esp, 4 * 3
The "4" is the size of the parameter in bytes, and the "3" is the number of parameters - change it if you change the number of parameters. Then we need to add "last" to "next to last" (they're at [ebp + 12] and [ebp + 16]). That becomes our "current" Fibonacci number. For the next call, our "current" number becomes "last" and our old "last" becomes "next to last", decrement the count and call ourself. Until done.
I'll show you what I came up with, but give it a shot yourself first.
Best,
Frank