welcome to just answer
are you present online?
black stools are mostly due to blood in stools
the cause for this can be bleeding due to a stomach ulcer, gastritis, esophageal varices (bleeding due to dilated veins in esophagus)
since you have been having this problem for a few months you need to be evaluated as soon as by your doctor
you might need an gastric endoscopy to visulaize your stomach for any ulcers
The other cause of black stools are ig you take regular iron supplements, take pepto-bismuth, blacl liquorice
but since you are having stomach cramps also, I would be concerned about presence of an ulcer and would recommend you to consult your doctor as soon as possible