Yes, sure it can be done.
As long as the adapters on the machines are fairly new, a cross-over cable will not be needed and a standard Cat5 can be used (or Cat5e, Cat6). If not so new, then a crossover cable is needed.
You have to set static ip addresses for each machine. One machine's ip address will be set as the other's default gateway.
For example -
Machine 1:
ip address = 10.1.1.1
default gateway = 10.1.1.2
Machine 2:
ip address = 10.1.1.2
default gateway = 10.1.1.1