29 March 2011, 20:05 | #1 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
|
Question about the TAS instruction.
Hi,
The 680x0 guide file I have, says this about the TAS instruction: Quote:
Any pointers are appreciated |
|
29 March 2011, 20:18 | #2 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,004
|
TAS isn't safe to use on Zorro II systems, as certain conditions are expected and never happen.
TAS is also not a good idea on Amiga as the instruction can cause a bus lock during an interrupt, with that certain part of memory thats been Tested and Set, is now not available to other processors, which will cause problems. From what I can remember, a TAS will cause a bus lock at any time, not at the end of of a interrupt cycle. |
29 March 2011, 20:32 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,519
|
It isn't safe.
One issue is TAS to chip RAM + Agnus DMA accesses at the same time = incorrectly working TAS. Problem is TAS's special cycle (read-modify-write cycle which is unsupported on Amiga) When TAS read cycle has finished, it can't be stopped anymore, write cycle will start and in worst case Agnus is also using this cycle for DMA (because it thought TAS read cycle was normal single read cycle) I haven't seen any bus lockups, only wrong TAS results (but I have only been testing it on chip RAM) |
29 March 2011, 20:51 | #4 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
|
Thanks guys
Pity, but luckily there's still BSET, so no problem. As long as testing and setting can't be interrupted, I'm happy |
31 March 2011, 18:06 | #5 |
Registered User
Join Date: Jun 2008
Location: somewhere else
Posts: 515
|
Does this rule apply to a "tas dx" like form ?
I seems to remember that what it does just set the bit 7 of the specified data register. |
31 March 2011, 20:43 | #6 |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
What is the purpose of the atomicity?
There is no atomic read+write operation against memory in the Amigas. (Unless CAS/CAS2 are supported, which I don't think they are.) So there is no way to perform an atomic read-modify-write operation, which is guaranteed not to be intercepted by another DMA capable device in the system. However if you seek atomicity with regards to interrupts within the same CPU, the situation is easier; the CPU will only check for external interrupts between the processing of two instructions. So, if you know that the instruction itself will not generate an exception (perhaps because you're attempting to read/write a page which has been marked as unavailable by the MMU) then you can implement semi-atomic operations by using ordinary logic operations where you can deduce the old value from the new. For instance a semaphore: Code:
acquireSemaphore: addq.b #1,semaphore ; attempt to acquire semaphore beq.s .done ; if current value = 0, you acquired it subq.b #1,semaphore ; wait for some time (or for an event) before re-trying bra.s acquireSemaphore .done: rts releaseSemaphore: subq.b #1,semaphore rts semaphore: dc.b 255 |
31 March 2011, 21:18 | #7 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,767
|
I need this for insuring that a task exception won't do certain things, such as killing the task, while the task is inside a critical section. I wanted to use TAS for this, but BSET works as well, because I don't need the read-write cycle, I just need a test and a write to be done in one go (using two instructions means the exception can happen after the test, and before the write and this is bad in my code).
Last edited by Thorham; 31 March 2011 at 21:24. |
03 April 2011, 13:12 | #8 |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 866
|
the question arises if tas/cas would be save on real fast mem? but afaik there can be dma too (for example scsi/ata/ethernet)
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
MUI Programming Instruction offered | AmigaDave | Coders. General | 2 | 03 May 2013 23:34 |
Optimizing question: instruction order | TheDarkCoder | Coders. Asm / Hardware | 9 | 29 October 2011 17:07 |
Instruction cache question | Lord Riton | Coders. General | 2 | 07 April 2011 12:25 |
Please help me: one by one instruction needed | JewStrangler | support.WinUAE | 15 | 20 September 2010 18:55 |
$48e70000 instruction | Asman | Coders. General | 5 | 10 February 2006 23:00 |
|
|