Calculating CPU time of IRQ outside of it

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Calculating CPU time of IRQ outside of it

Post by Twilighte »

This is just a short routine to calculate the cpu time taken during an irq triggered by Timer 1 of the VIA.

Code: Select all

#define	via_portb		$0300
#define	via_t1cl		$0304
#define	via_t1ch		$0305
#define	via_t1ll		$0306
#define	via_t1lh		$0307
#define	via_t2ll		$0308
#define	via_t2ch		$0309
#define	via_sr			$030A
#define	via_acr			$030b
#define	via_pcr			$030c
#define	via_ifr			$030D
#define	via_ier			$030E
#define	via_porta		$030f

Code: Select all

loop1	;Capture times
	lda via_t1cl
	sta temp_cl
	lda via_t1ch
	sta temp_ch
	lda via_t1ll
	sta temp_ll
	lda via_t1lh
	sta temp_lh
	;
	lda temp_ch
	cmp old_ch
	bcc loop1
	;IRQ Occurred
	sta old_ch
	;Calculate cycles used by irq
	lda temp_ll
	sbc temp_cl
	sta cycles_lo
	lda temp_lh
	sbc temp_ch
	sta cycles_hi
                rts