Hi,
You are referring to feedback. There are several variables: positioning of mic and speaker, polar pattern of mic, and volume of sound are some.
First off, a mic should never be pointed in the general direction of a speaker if that speaker is reproducing the signal of the mic unless you are in a very expensive stage situation where such things can be dealt with.
Putting the mic to the side of the speaker, facing away, or (ideally) behind it should help kill the howl. The mic should be somewhat directional; you don't want an omni mic in such a setup.
A small room can make it worse by bouncing reflections, so dampening the room might help, but too much volume can do you in any day. If it's really loud, feedback will most likely come around no matter what you do, if you are in a small space or a big one and you don't have a pro setup.
Try with the mic positioning and type first, along with experimenting with the tone controls of the mic input or the amp to see which frequencies (low/mid/high) are causing the feedback. The turn those frequencies down to see what happens and how much or little is needed. And watch the volume.
Just some general advice, but it may help you.
Best,
C.