RST $38 T-states (Development MSX Forum)MSX Resource Center               
              
English Nederlands Espa�ol Portugu�s Russian         
 News
   Frontpage
  News archive
  News topics

 Resources
   MSX Forum
  Articles
  Reviews
  Fair reports
  Photo shoots
  Fairs and meetings
  Polls
  Links
  Search

 Software
   Downloads
  Webshop

 MRC
   Who we are
  Join our team
  Donate
  Policies
  Contact us
  Link to Us
  Statistics

 Search
 
  

  

 Login
 

Username

Password




Don't you have an account yet? Become an MSX-friend and register an account now!.


 Statistics
 

There are 38 guests and 1 MSX friend online

You are an anonymous user.
 

MSX Forum


MSX Forum

Development - RST $38 T-states

Author

RST $38 T-states

Metalion
msx freak
Posts: 241
Posted: October 04 2007, 20:50   
Hi,

Does someone know how much T-states the generic interrupt handler uses in the main ROM ?
I know that it depends from the model and/or the ROM, but any input is welcome.
Of course, I know I could do it myself by disassembling the ROM, but it is a waste of time if the info is already out there
dvik
msx master
Posts: 1343
Posted: October 05 2007, 01:27   
You can also use an emulator. I think both bluemsx and openmsx have some sort of T-state counter, so just set a breakpoint at $38 and see how long it takes.
Metalion
msx freak
Posts: 241
Posted: October 05 2007, 07:24   
Quote:

I think both bluemsx and openmsx have some sort of T-state counter


Well, I've checked the BlueMSX emulator and I did not find such a tool.
Maybe it was implemented in v2.7 (I am still using the v2.6.1 at the moment) ?
norakomi
msx professional
Posts: 861
Posted: October 05 2007, 10:27   
Quote:

Hi,

Does someone know how much T-states the generic interrupt handler uses in the main ROM ?
I know that it depends from the model and/or the ROM, but any input is welcome.
Of course, I know I could do it myself by disassembling the ROM, but it is a waste of time if the info is already out there

you can also use bluemsx's debugger to step through the interrupt handler, and write down the T-states of all the instructions you see there.
That will take an hour maybe.
There is also documentation about the main ROM routines. Maybe that's easier to work with.
But if there is a T-state counter in blue or open, then thats the best alternative !!
dvik
msx master
Posts: 1343
Posted: October 05 2007, 17:30   
I think 2.7 has one in the CPU register window. 2.6 only has a scanline counter in the VDP register window and that may work too if you don't need to know the exact count
caro
msx freak
Posts: 138
Posted: October 05 2007, 21:24   
Hi
Quote:

Does someone know how much T-states the generic interrupt handler uses in the main ROM ?

Simple programm for count takts for RST 38h
caro.k66.ru/files/test-rst.zip

For my clone OCM on Altera DE1:
-------------------------------
Total takts per INT= 59724
Takts for RST 38h = 6552

manuel
msx guru
Posts: 3545
Posted: October 05 2007, 22:59   
On a Philips NMS 8250: 71352 and 6876 (openMSX); 71370 and 6876 (real enhanced 8250)
turboR: 484161 and 9324 (openMSX); 317358 and 9990 (real GT).

Note that the numbers change with every run, so something doesn't seem to be completely right!
Metalion
msx freak
Posts: 241
Posted: October 05 2007, 23:18   
@caro : Thanks for your tool !! Exactly what I needed ! Could you post the source ?

Quote:

On a Philips NMS 8250: 71352 and 6876 (openMSX); 71370 and 6876 (real enhanced 8250)
turboR: 484161 and 9324 (openMSX); 317358 and 9990 (real GT).



Thanks also for those results.
I know now that the interrupt handler takes longer on a Turbo-R
Although I would need the result in Z80 mode.
Could you do it again for me ?

Quote:

Note that the numbers change with every run, so something doesn't seem to be completely right!


Actually, the interrupt handler scans the keyboard and other peripherals, so I figure it's normal if the timing changes (if a key is pressed for example). On the other side, I don't see why the T-states counting of a frame should change, it is fixed. It's easy to calculate :

50Hz : 1.000.000 µsec / 50 x 3,579545 MHz = 71590 T-states
60Hz : 1.000.000 µsec / 60 x 3,579545 MHz = 59659 T-states



caro
msx freak
Posts: 138
Posted: October 06 2007, 20:57   
Quote:

Could you post the source ?


;----------------------------------------
;	Count takts per INT		!
;	(c) 2007 caro (Kamil Karimov)	!
;----------------------------------------
.z80
;
VDP_ST	equ	99h	;port status VDP
ad_tab	equ	9100h	;tab vectors im 2
;========================================
	.phase	9000h-7
	db	0feh	;flag binare
	dw	test2	;adr begin
	dw	a_end	;adr end
	dw	test2	;adr start
;----------------------------------------
test2:	jr	start
;----------------------------------------
;&H9002
res_1:	dw	0	;result without RST 38
;&H9004
res_2:	dw	0	;result with RST 38
;----------------------------------------
; set INT mode 2
start:	di
	ld	a,high ad_tab	;
	ld	i,a		;
	ld	hl,ad_tab	;table INT vectors
	ld	de,ad_tab+1
	ld	bc,100h
	ld	(hl),90h	;adr vector = 9090h
	ldir
	ld	a,0c3h          ;jp
	ld	(9090h),a	;
	ld	hl,a_int	;INT handler
	ld	(9090h+1),hl
	im	2
;/-------------------------------------------
; count takts per INT without RST 38h
	ld	hl,s_int
	ld	(a_int+1),hl
	ld	de,0+4		;counter takts = 0
	ei			;
	halt			;wait INT (A=0,Z=1)
	inc	a		;A=1,Z=0
	ei			;
; wait next INT (A=0,Z=1)
ckl_1:	inc	de		;4+1
	jp	nz,ckl_1	;12+1
; Z=1
	di
	ld	(res_1),de	; result 1
;----------------------------------------------
; count takts per INT with RST 38h
	ld	hl,0038h
	ld	(a_int+1),hl
;
	ld	de,0+4		;counter takts = 0
	ei			;
	halt			;wait INT (A=0,Z=1)
	inc	a		;A=1,Z=0
	ei			;
; wait next INT (A=0,Z=1)
ckl_2:	inc	de		;4+1
	jp	nz,ckl_2	;12+1
				;18 takts per cikl
	di
	ld	(res_2),de 	;result 2
	im	1
	ei
	ret			;exit
;----------------------------------------------
; handler hardware INT
a_int:	call	s_int		; or RST 38h
	xor	a		;Z=1
	ret
;-----
s_int:	in	a,(VDP_ST)	;reset VDP INT
	ret
;----------------------------------------------
a_end:
	end


Metalion
msx freak
Posts: 241
Posted: October 07 2007, 20:17   
Thanks for your source ..... Although .... I don't understand how it works.
Must be all the beer from yesterday evening

Could you explain the principle used to count T-states ?
caro
msx freak
Posts: 138
Posted: October 08 2007, 08:56   
Quote:

Could you explain the principle used to count T-states ?



I shall try to explain.

In an interval between two INT the cycle works, in which to register pair DE increases 1.
The termination of a cycle is the installation of a flag Z in 1, that is provided with
operation XOR A in procedure of processing of interruption.
As the duration of performance of command of the processor Z80 is fixed and is known
(in this case is equal to 18 T-state), the value of DE at an exit from a cycle
will give number on which it is possible to define number of T-state between
two interruptions: N = (DE)*18
The minimal time of performance of interruption and time of performance
of additional command is taken into account by installation of the counter
of cycles DE=4.


 
 







(c) 1994 - 2008 MSX Resource Center Foundation. MSX is a trademark of MSX Licensing Corporation.