Byte-Banging 2 8051's using port addresses
In general, you shouldn't be using timed waits at all. Rather, you should be using a handshake that guarantees that the events on the databus occur in the required order.

Those events are:


Master drives data bus
Master releases data bus
Slave drives data bus
Slave releases data bus


Unfortunately, only two additional signals is not enough to manage this process for a bidirectional bus. You'll need at least one other signal connected between the two processors. There are a number of ways you could use such a signal. One of the simplest is to treat it as a read/write signal, controlled by the master CPU.

The transaction would then go something like this.


Master drives data bus, sets read/write low (write) , then asserts the CMD signal.
Slave observes CMD asserted, reads the read/write signal, and then reads data bus and then asserts ACK.
Master observes ACK asserted, tristates the data bus, then negates CMD.
Slave observes CMD negated, and negates ACK.


Note that if the slave is busy with something else when the master starts the transaction, it simply delays asserting ACK in step 2. The master waits as long as necessary.

To transfer the result:


Master leaves data bus tristated, sets read/write high (read), then asserts the CMD signal.
Slave observes CMD asserted, reads the read/write signal. It then drives the result onto data bus and asserts ACK.
Master observes ACK asserted, reads the data bus, then negates CMD.
Slave observes CMD negated, tristates the data bus and negates ACK.


Note that if the slave requires some time to compute its result, it simply  delays asserting ACK in step 6, and the master will simply wait as long as needed.