Question

I have this delay routine in assembly language, can anybody explain me how this works? I'm very much new to assembly and trying to understand the insights. Can anybody help me understand the functionality of PUSH & POP? Any help will be appreciated :)

    DELAY: MOV CX, 0FFH

    DLY5: PUSH CX
          MOV CX, 03FFH

    DLY10: NOP
           LOOP DLY10
           POP CX
           LOOP DLY5
           RET
Was it helpful?

Solution

The push/pop in this case serves to run the outer loop. and only use one register for the whole delay, while having two counters (inner loop with 03FFH and outer loop with 0FFH).

Maybe the author didn't want to spoil another register, or he wanted to use the loop instruction which requires the cx register.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top