![]() |
![]() |
#1 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
CIA test
Run following code on your real Amiga (include model) without startup-sequence and if possible, explain the return value and value you expected.
I can't explain it ![]() Executable attached, source below. Code:
; WARNING: ugly code ahead! :) lea $dff000,a6 ; disable interrupts move.w $1c(a6),d7 move.w #$7fff,$9a(a6) ; CIA-B base address lea $bfd000,a0 ; disable interrupts move.b #$7f,$d00(a0) ; release possible TOD read latch move.b $800(a0),d0 ; clear possible old interrupts move.b $d00(a0),d0 ; write 0x000000 to ALARM bset #7,$f00(a0) move.b #0,$a00(a0) move.b #0,$900(a0) move.b #0,$800(a0) ; write 0x000002 to TOD bclr #7,$f00(a0) move.b #0,$a00(a0) move.b #0,$900(a0) move.b #2,$800(a0) moveq #$40,d1 l2 move.b $900(a0),d0 ; TOD 0x004000 or higher? cmp.b d1,d0 bcc.s l1 ; ALRM interrupt? btst.b #2,$d00(a0) beq.s l2 l1 ; read TOD moveq #0,d6 move.b $a00(a0),d6 lsl.l #8,d6 move.b $900(a0),d6 lsl.l #8,d6 move.b $800(a0),d6 ; restore interrupts move.w #$7fff,$9a(a6) or.w #$8000,d7 move.w d7,$9a(a6) ; output D6 to CLI move.l 4,a6 lea dos(pc),a1 moveq #0,d0 jsr -$0228(a6) move.l d0,a3 move.l d6,-(sp) lea s(pc),a0 move.l sp,a1 lea putchar(pc),a2 jsr -$020a(a6) addq.l #4,sp move.l a3,a1 jsr -$019e(a6) moveq #0,d0 rts putchar movem.l d0-d3/a6,-(sp) and.w #$ff,d0 beq.s pc1 move.w d0,d3 move.l a3,a6 jsr -$03c(a6) move.l d0,d1 beq.s pc1 move.w d3,-(sp) move.l sp,d2 addq.l #1,d2 moveq #1,d3 jsr -$0030(a6) addq.l #2,sp pc1 movem.l (sp)+,d0-d3/a6 rts dos dc.b 'dos.library',0 s dc.b '%ld',10,0 |
![]() |
![]() |
#2 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 43
Posts: 2,351
|
Amiga 500/68000/KS1.3/512K+512K+4M: 4096
Amiga 4000/68060/KS3.1/2M+16M+128M: 4096 CD32/68030/KS3.1/2M+16M: 4096 Still thinking about result... |
![]() |
![]() |
#3 |
.
Join Date: Oct 2004
Location: Ioannina/Greece
Posts: 5,040
|
what does it mean?
|
![]() |
![]() |
#4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
It means:
- my program has a bug or - CIA ALRM interrupt does something undocumented. |
![]() |
![]() |
#5 |
.
Join Date: Oct 2004
Location: Ioannina/Greece
Posts: 5,040
|
oh, thanx
![]() |
![]() |
![]() |
#6 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 43
Posts: 2,351
|
To be honest Toni, my knowledge of the CIAs is a bit lacking... I think I've got an idea where you are going with this, but what were you expecting and why... ?
|
![]() |
![]() |
#7 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
It sets ALARM to zero, TOD to 2, waits until ALARM interrupt triggers which _should_ only happen when ALARM == TOD -> only after TOD wraps around after about 17 minutes.
But my test program triggers the interrupt when TOD == 0x1000 (4096). It should return 16384 (0x4000, the limit value) Interestingly this weird feature only triggers if ALARM equals zero. Added: Quote:
Last edited by Toni Wilen; 26 October 2006 at 13:15. |
|
![]() |
![]() |
#8 |
In deep Trouble
Join Date: Sep 2004
Location: Manchester, Made in Norway
Age: 51
Posts: 841
|
it's possible that this bug might have had something they desired, and thus left it in there? Either that, or they didn't know what triggered the bug. Your pick
![]() What is TOD anyways? Time Of Delay or something? and why 17 minutes? it sure doesn't take even the A500 to count from 2 to 16384 17 minutes :scratch |
![]() |
![]() |
#9 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
TOD = Time Of Day.
I think the name originally come from 6526 CIA, used in C64 for example, which had "real" TOD, Hours/Mins/Seconds/10thseconds BCD counters. 8520 is 6526 + 4 register BCD TOD counter replaced with 3 register 24-bit binary counter. All other functions are exactly same. CIA-B TOD counts horizontal syncs = 24-bit counter overflows in about 17 minutes (2^24 / (312 * 50) = 1075 seconds = 17.9 minutes. (PAL) Counting to 16384 takes only ~1 second. |
![]() |
![]() |
#10 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
![]()
Hahaa, it is real hardware bug, but not in ALARM == TOD comparator. TOD incrementation logic is buggy..
I added following code: Code:
.. lea out(pc),a1 moveq #-1,d2 move.b $900(a0),d0 cmp.b d0,d2 beq.s same move.b d0,d2 move.b d0,(a1)+ same: ; TOD 0x004000 or higer? ... out: dcb.b 10000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 10 11 12 13... ADDED: 0F->00->10 transition takes only couple of cycles (maybe one E-clock cycle?) so TOD does not lose time because of this bug. Programs that read TOD properly (=all programs most likely) by reading MSB first which enables read-latch don't see anything wrong. Last edited by Toni Wilen; 26 October 2006 at 18:36. |
![]() |
![]() |
#11 |
In deep Trouble
Join Date: Sep 2004
Location: Manchester, Made in Norway
Age: 51
Posts: 841
|
Okays...... 1075secs ..... 17mins 55secs...... so nearly 18 mins..... get your maths right, Tony :P
However, on a serious note, I see where you were completely confuzzeled before...... things should not go from 15 to zero to 16 like that. |
![]() |
![]() |
#12 | |
Mostly Harmless
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,149
|
Quote:
![]() ![]() A couple of questions spring to mind:
|
|
![]() |
![]() |
#13 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
TODLOW does not have the bug. TODHI not yet tested.
(17 or 18 minutes, who cares? I remember it being 17.something and I was too lazy to calculate it yet again) |
![]() |
![]() |
#14 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
|
Documenting another CIA feature/bug here:
Read access to TODHI does not latch the timer if ALARM-bit in control register B (CRB) is set. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
example of a CIA timer interrupt in assembler using cia.resource | Apollo | Coders. Asm / Hardware | 3 | 05 July 2013 08:40 |
CIA chips | Yakumo9275 | support.Hardware | 3 | 23 March 2013 18:56 |
A1200 possible CIA fault | edimax | support.Hardware | 11 | 20 May 2012 23:16 |
Amiga CIA Questions | EvilCensor | support.Hardware | 1 | 06 August 2010 19:11 |
CD32 Frog Feast test available. Test out the final! | cdoty | News | 42 | 01 April 2008 16:20 |
|
|