Not sure which ROM you're hacking, but I was coincidentally poking Knizz's (FireRed) idb the other day.
There's a subroutine at 0x0803E89C. Set r0 to the pokemon's offset and r1 to the move halfword. If the pokemon has space in its moveset, it automatically teaches the move. It doesn't teach the move if the pokemon's moveset is full, but I'd guess that a routine that calls it does, because it also returns FFFE if the pokemon knows the move and FFFF if the pokemon already has four moves. It's used in a number of things like TM's, level up, even daycare. Probably everything. I can't really check right now, but I bet that if you look around there, you'll find what you're looking for.