Cross-feeding interactions are a common feature of many microbial systems, such as colonies of Escherichia coli grown on a single limiting resource, and microbial consortia cooperatively degrading complex compounds. We have studied this phenomenon from an abstract point of view by considering artificial organisms that metabolize binary strings from a shared environment. The organisms are represented as simple cellular automaton rules and the analog of energy in the system is an approximation of the Shannon entropy of the binary strings. Only organisms that increase the entropy of the transformed strings are allowed to replicate. This system exhibits a large degree of species diversity, which increases when the flow of binary strings into the system is reduced. Investigating the relation between ecosystem productivity and diversity we find that diversity is negatively correlated with biomass production and energy uptake, while it correlates positively with energy-uptake efficiency. By performing invasion experiments, we show that the source of diversity is negative frequency-dependent selection acting among the different species, and that some of these interactions are intransitive, another mechanism known to promote diversity.