This task was so easy in the good old days: write a program that makes a database of all the executables (exe, bat, pif, dll, etc.) with their name and size (or CRC) when the system is clean, then periodically verify them -- an infected file could have different size and surely different CRC. If you add a boot-sector check too then you'll have a bulletproof antivirus for all the viruses that are older than a decade.
But today's viruses are much cleverly written and you could identify them only by they signature. So even if you manage to write an antivirus program, updating it's signature database would be a full-time job...