More information needed. I understand you want code that will multiplex a 4 digit 7 segment display, which is the simple part. But as far as the counter/switch part, are you wanting to make the digits count up starting from 0 to 9999 when the button is pressed?
If you cant be bothered to write and want something done for you..use the 8052 site here is an example of what you want **broken link removed** 7 segment display calculator