Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;(c)2020 Miguel Angel Rodriguez Jodar.
- org 8100h
- Start di
- ld a,81h
- ld i,a
- im 2
- jp RealStart
- org 81FFh
- dw NewIM2
- NewIM2 ei
- PatchHere ret ;later, this will be ex (sp),hl ;10T / 19T
- ld d,h
- ld e,l
- ld c,b
- im 1
- ex (sp),hl
- ret
- ReturnFromNOPs di
- ld a,c
- ld (23728),a ; Number of complete loops executed
- ld hl,StartNOPs
- or a
- ex de,hl
- sbc hl,de ;
- ld b,h ;
- ld c,l ; Return value: number of NOPs in last iteration of loop
- ei ; Frequency (MHz) = (peek(23728)*10010+BC*4+60)/19968
- ret
- RealStart ld a,201 -
- ld (PatchHere),a ;init interrupt
- ei
- halt
- ld hl,ReturnFromNOPs
- push hl
- ld hl,551 ;loop to wait for aprox. 14336 cycles
- WaitContended dec hl
- ld a,h
- or l
- jr nz,WaitContended ;wait until we are in the contended area
- ld a,(16384) ;contended operation to sync HALT
- ;----------- Time measuring starts here!
- halt ;33T, including intack, int routine and return
- ld a,0e3h ; 7T
- ld (PatchHere),a ;13T
- ld b,0 ; 7T
- ;-----
- ;60T pre-loop time
- StartNOPs
- rept 2499 ;4T per NOP
- nop
- endm
- inc b ; 4T
- jp nz,StartNOPs ;10T ;----- 10010T per loop
- ret
- end Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement