In line 2, ds:[di] correctly points to the start of the buffer. The first 65536 bytes are correctly filled with zeros in lines 1-6. Lines 11-17 are intended to continue where lines 1-6 leave off, however ds must be reset in lines 7-10 so that ds:[di] in line 12 points to the physical address located 65536 bytes after the start of the buffer. This is the problem. Lines 7-10 increment ds by 1 under the assumption that each segment begins where the previous one leaves off. However, from equation 1, we know that by incrementing ds, the physical address of ds:[di] is only increasing by 16 bytes, rather than 65536 bytes. This means that lines 11-17, instead of filling zeros starting 65536 bytes into the buffer, are merely filling zeros starting with 16 bytes into the buffer. These bytes have already been filled with zeros from the first loop in lines 1-6, so the later part of the buffer ( beginning with offset 65536 ) never gets filled with zero's.
In order to remedy the problem, we need to find the correct value to add to ax in line 9. This value needs to be one sixteenth of the change we want in the physical address of ds:[di]. Since we want to increase the physical address by 65536, ax needs to be increased by 4096. Therefore, the problem can be remedied by replacing line 9 with :
add ax,4096