If a game has a sound test, then all you have to do is just record the sounds, keeping in mind that some games might not have all the sounds in the test. If a game doesn't have a sound test and quite a lot don't, then you would have to either hack codes to get sounds or disassemble the sound engine which is pretty hard unless you know what you're doing. For the latter you need to know assembly (like for GBA games, ARM assembly) and look for sound related calls.