As a first step, you do not need to save to the shadow register and load from it so many times. Only one load and one save. This shortens the pulse
push af ;; 11
ld a, (PCDRshadow) ;; 9 Make sure other bits are not changed
res 5, a ;; 4 Assume pulse is active low
ioi ld (PCDR), a ;; 11 Emit pulse
set 5, a ;; 4 Remove pulse again
ioi ld (PCDR), a ;; 11 and output it; width is only 15 clocks
ld (PCDRshadow), a ;; 10 Restore state in case PCDR used elswhere
pop af ;; 7
If you want a stream of pulses you can replicate the middle code as follows:
push af ;; 11
ld a, (PCDRshadow) ;; 9 Make sure other bits are not changed
res 5, a ;; 4 Assume pulse is active low
ioi ld (PCDR), a ;; 11 Emit pulse
set 5, a ;; 4 Remove pulse again
ioi ld (PCDR), a ;; 11 and output it; width is only 15 clocks
res 5, a ;; 4 Assume pulse is active low
ioi ld (PCDR), a ;; 11 Emit pulse
set 5, a ;; 4 Remove pulse again
ioi ld (PCDR), a ;; 11 and output it; width is only 15 clocks
// ... add more or put into djnz loop
res 5, a ;; 4 Assume pulse is active low
ioi ld (PCDR), a ;; 11 Emit pulse
set 5, a ;; 4 Remove pulse again
ioi ld (PCDR), a ;; 11 and output it; width is only 15 clocks
ld (PCDRshadow), a ;; 10 Restore state in case PCDR used elswhere
pop af ;; 7
For a faster pulse stream, you can load the “set” value in register b, the “reset” value into register c and the destination port into hl:
push af ;; 11
push bc
push hl
ld a, (PCDRshadow) ;; 9 Make sure other bits are not changed
res 5, a ;; 4 Assume pulse is active low
ld b, a
set 5, a ;; 4 Remove pulse again
ld c, a
ld (PCDRshadow), a ;; 10 Restore state in case PCDR used elswhere
ld hl, PCDR ;; Port address to hl
ioi ld (hl), b ;; (6+ioi) Emit pulse
ioi ld (hl), c ;; (6+ioi) turn off
pop hl
pop bc
pop af ;; 7