89C2051 has the same core as that of 8051/8031. The only differenece is that it has 2kB of FLASH ROM and has only 20 pins. Rest everything is same. You can use it in place of 8051/31 provided that your code does not use port pins which it does not have.
Standard 8051 - 4k EPROM/OTPROM
Standard 8031 - ROMLESS