English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 22 December 2013, 14:49   #1
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,349
DSKINDEX bit

Something I noticed when testing (using WinUAE but I assume this matches a real Amiga).

Reading the Amiga Hardware Reference Manual, the CIA B ICR register ($BFDD00) FLAG bit (bit 4) is shown as DSKINDEX* which implies that signal is active low. And it does seem to be; reading $BFDD00 while running a program which uses trackdisk.device to read a disk returns $10 most of the time, occasionally $00. But when no drive is selected (no disk activity) that bit always reads as zero.

Edit: I think that's wrong. It seems the FLAG bit doesn't track the state of the index line directly, but is set when the CIA chip "sees" an index pulse. It is reset on reading CIA B ICR. So basically, CIABICR FLAG bit = 1 means "there has been an index pulse since the register was last read". (I don't know whether the FLAG bit goes high on the leading or trailing edge of the index pulse, or what delay there is between the actual floppy drive index line transition and the FLAG bit being set in CIABICR.)

Last edited by mark_k; 22 December 2013 at 18:08.
mark_k is offline  
Old 22 December 2013, 21:33   #2
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,349
Another disk index-related question, I might as well write here instead of making a new thread.

Suppose I'm polling in a tight loop for the disk index pulse. Which has lower latency: reading CIA B ICR or checking the EXTER bit in INTREQR?

CIA registers are slower to read than custom chip registers. But is there a delay between the CIA B ICR FLAG bit being set and the EXTER bit in INTREQR being set? Assume interrupts and display/blitter/sprite DMA are disabled and code is running from fast RAM.

Loop reading the CIA B ICR FLAG bit directly. D0 contains CIAICRB_FLAG (4), A0 points to CIAB ICR B ($BFDD00).
Code:
 TST.B	(A0)		;Make sure bit is clear before looping 
WaitForIndex:
 BTST.B	D0,(A0)
 BEQ.B	WaitForIndex
Loop checking the EXTER bit in INTREQR. D1 contains INTB_EXTER-8, A1 points to INTREQR.
Code:
 TST.B	(A0)		;Clear FLAG bit in CIA B ICR
 MOVE.W	#INTF_EXTER,(intreq).L	;Clear EXTER bit

WaitForIndex2:
 BTST.B	D1,(A1)
 BEQ.B	WaitForIndex2

Last edited by mark_k; 22 December 2013 at 22:48.
mark_k is offline  
Old 22 December 2013, 22:11   #3
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
CIAs are driven by the E clock (much slower, see the hardware manuals for 68K family), and clocking in external signals is possibly not a single cycle operation either. So chances are, you want to read INTREQ.
IFW is offline  
Old 23 December 2013, 08:16   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,573
EXTER signal comes from CIA and CIA interrupt generation is also synced to E-clock and there is also 2 color clock delay before Paula sees changed interrupt state.

Also I think it is also possible to read active interrupt status from CIA register before CIA enables the physical interrupt signal. (I did test this long time ago.)

So technically reading CIA register should be (slightly) faster.

EDIT: but if you only have chip ram (or slow ram) and CPU without instruction cache, it probably makes no difference because even in fastest case your checking loop has at least 2 instruction fetches (2x4 CPU clocks in best case), which will add at least 1 extra E-clock of noise to your calculations.

Last edited by Toni Wilen; 23 December 2013 at 08:23.
Toni Wilen is offline  
Old 23 December 2013, 09:26   #5
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
I should have checked the schematics
IFW is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best Way to Convert 32-bit Signed Value to 16 Bit? AGS Coders. Asm / Hardware 31 29 December 2013 13:58
32-bit access on 16-bit bus? NorthWay Coders. Asm / Hardware 7 04 September 2013 00:46
REQ: 17-Bit Artwork 2 (1988-04)(17-Bit Software) Sea7 request.Demos 5 13 May 2011 01:07
8 bit to optimized 6 bit palette histogram improvements needed NovaCoder Coders. General 0 14 April 2011 02:13
My A500 is dying bit by bit :( Old Fool support.Hardware 3 03 July 2009 17:12

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:38.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14939 seconds with 15 queries