Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .assume adl=1
- ; Sleeps for HL microseconds.
- ;
- ; Includes the time to call and return from thus function. Assumes a CPU speed
- ; of 48MHz and 3 cycles of memory read waitstates (ex. RAM).
- ;
- ; It is not possible to sleep for 0 or 1 microsecond. Best effort implementation
- ; sleeps instead for 1.33 microseconds (repeating, of course).
- ;
- ; I: UHL=microseconds
- ; FO: c=0
- ; If UHL>=2:
- ; O: ude=-1, uhl=-1
- ; CC: (11*r(PC)+4)*(UHL-2)+14*r(PC)+3*r(SPL)+6
- ; If UHL<2:
- ; O: ude=-2, uhl=UHL-2
- ; CC: 7*r(PC)+3*r(SPL)+2
- Sleep:
- ld de,-2
- add hl,de
- ret nc
- Sleep_Loop:
- ld e,-1
- ret nc
- ret nc
- ret nc
- add hl,de
- ret nc
- nop
- jr Sleep_Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement