Advertisement
Runer112

Sleep

May 2nd, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. .assume adl=1
  2.  
  3. ; Sleeps for HL microseconds.
  4. ;
  5. ; Includes the time to call and return from thus function. Assumes a CPU speed
  6. ; of 48MHz and 3 cycles of memory read waitstates (ex. RAM).
  7. ;
  8. ; It is not possible to sleep for 0 or 1 microsecond. Best effort implementation
  9. ; sleeps instead for 1.33 microseconds (repeating, of course).
  10. ;
  11. ; I: UHL=microseconds
  12. ; FO: c=0
  13. ; If UHL>=2:
  14. ; O: ude=-1, uhl=-1
  15. ; CC: (11*r(PC)+4)*(UHL-2)+14*r(PC)+3*r(SPL)+6
  16. ; If UHL<2:
  17. ; O: ude=-2, uhl=UHL-2
  18. ; CC: 7*r(PC)+3*r(SPL)+2
  19. Sleep:
  20. ld de,-2
  21. add hl,de
  22. ret nc
  23. Sleep_Loop:
  24. ld e,-1
  25. ret nc
  26. ret nc
  27. ret nc
  28. add hl,de
  29. ret nc
  30. nop
  31. jr Sleep_Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement