28 February 2016, 15:58 | #1 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 65
|
CIA Interrupts and Timers and Ports
CIA A and CIA B are said to be able to generate INT2 and INT6 accordingly... but I don't know what INT2 and INT6 are referring to... my three theories would be:
- INT2/INT6 are causing Bit2/Bit6 in INTREQR to be set (that would be "SOFT" and "BLIT")? - INT2/INT6 are meaning CPU Interrupt Level2/Level6 and do set Bit3/Bit13 in INTREQR (that would be "PORTS" and "EXTER")? - INT2/INT6 might refer to CPU Interrupt Level2/Level6 but do not affect any bits in INTREQR? Am I on the right way, or is it working even differently? Here's some kickstart code that doesn't work right in my emu, and I am having problems to imagine how it could/should work at all. Caution: The disassembler syntax used here is showing operands ordered as "destination,source" (unlike normal 68000 syntax). Code:
FE9292 call 0FE953Ah ;-init some CIA stuff FE9296 movb [0F00h+a0],8h ;-stop timer b FE929C movb [600h+a0],0FFh ;\timer b reload = FFFFh FE92A2 movb [700h+a0],0FFh ;/ FE92A8 movw [0DFF09Ah],4000h FE92B0 addb [126h+a6],1 FE92B4 call 0FE930Eh ;@@waitvsync ;-wait, with timer b stopped ??? FE92B8 movb [0F00h+a0],19h ;-start/load timer b FE92BE call 0FE930Eh ;@@waitvsync ;-wait, with timer b running FE92C2 movb [0F00h+a0],8h ;-stop timer b FE92C8 movd d0,0h FE92CA movb d0,[700h+a0] FE92CE shld d0,8 FE92D0 movb d0,[600h+a0] FE92D4 subb [126h+a6],1 FE92D8 jge 0FE92E2h ;@@cont1 FE92DA movw [0DFF09Ah],0C000h @@cont1: FE92E2 cmpw d0,0CCDDh FE92E6 ja 0FE92F0h ;@@cont2 FE92E8 movd d0,32h FE92EA movw d1,4E20h FE92EE jmp 0FE92F6h ;@@cont3 @@cont2: @@amok_jump: FE92F0 movd d0,3Ch FE92F2 movw d1,411Bh @@cont3: FE92F6 movw [22h+a2],d0 FE92FA movw [24h+a2],d1 FE92FE movb [213h+a6],d0 FE9302 movd a1,a2 FE9304 call 0FFFFFE50h+a6 FE9308 popd d2,a2,a3 FE930C ret ;--- @@waitvsync: FE930E movb d0,[800h+a0] ;-TOD.lsb @@wait_lop: FE9312 cmpb d0,[800h+a0] ;-TOD.lsb FE9316 jnz 0FE9336h ;@@wait_done FE9318 tstb [700h+a0] ;-timer b.msb FE931C js 0FE9312h ;@@wait_lop FE931E pushd d7,a5,a6 FE9322 movd d7,15000002h FE9328 movd a6,[4h] FE932C call 0FFFFFF94h+a6 FE9330 popd d7,a5,a6 FE9334 jmp 0FE92F0h ;@@amok_jump ;<-- go amok without "ret" ??? @@wait_done: FE9336 ret The first call to "@@waitvsync" seems to have three problems: - Timer B counter is still unitialized (only the reload value is initialized) - Timer B is stopped - And, assuming that uninitialized counter would be less than 8000h: The jump at FE931C wouldn't be taken, so following code would hit the "@@amok_jump" stuff (with the return address being left on stack, and thus crashing a moment later; that looks really like a bug in the kickstart rom). The code would pass without crashing if something would initialize Timer B counter to a value of 8000h..FFFFh. Is that happening anywhere? Maybe upon Reset? Or maybe anytime when stopping the Timer? Or when writing to the Timer reload value, is that also changing the counter value? Official docs say that counter is read-only though. Or well, maybe I am still having bugs in my disassembler, or my emulation has failed to execute some important CIA initialization function. Oh, and what is the "Memory Overlay" bit (in CIA A Port A Bit 0) doing? Is that bit causing ROM to be mirrored to address 00000000h (so the CPU could fetch the Reset vector from ROM)? Last edited by nocash; 29 February 2016 at 09:04. |
28 February 2016, 16:50 | #2 | |||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,570
|
That strange m68k disassembly syntax is unreadable..
Quote:
Quote:
Quote:
|
|||
28 February 2016, 20:20 | #3 |
Amigan
Join Date: Feb 2012
Location: London
Posts: 1,317
|
|
06 April 2016, 00:15 | #4 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 65
|
Thanks, Toni! That answers helped me to get through some problems (oh, and sorry for not replying earlier).
|
06 April 2016, 09:50 | #5 |
Registered User
Join Date: Jul 2014
Location: Finland
Posts: 1,186
|
That disassembly output just made me puke
|
06 April 2016, 13:42 | #6 |
Registered User
Join Date: Oct 2014
Location: Germany
Posts: 195
|
Uahh... come on, use another disassembler
|
09 April 2016, 01:47 | #7 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,655
|
It's "68000 8086 style" syntax? I think i saw it once before. I do agree it's horrible, of course. Original syntax is & was always a strength of 680x0. You could read it like a novel <3
From this I'm thinking the confusion might be partly "IRQ vs INT". In all CPUs, IRQ is an interrupt request and INT is an interrupt. On old PCs it's more well-known as "a way to invoke an interrupt". Whatever that shit is about. Well, it's about BIOS How the interrupts work in CPUs is explained as applied on Amiga with code examples in Amiga System Programmer's Guide which is available as PDF on archive.org. For a formally correct explanation without code examples, turn to Amiga Hardware Reference Manual, which is available online at dev.elowar.com. Sorry if you knew all this, links are just for completeness. |
13 April 2016, 12:09 | #8 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 65
|
Yes, 8086 syntax. I can only read that kind of code like a novel, but yeah, it depends on what you are familar with, seeing code with reversed source/dest ordering can be quite a brainkiller.
Anyways, back to first seven lines of my disassembly: Code:
FE9292 call 0FE953Ah ;-init some CIA stuff FE9296 movb [0F00h+a0],8h ;-stop timer b FE929C movb [600h+a0],0FFh ;\timer b reload = FFFFh FE92A2 movb [700h+a0],0FFh ;/ FE92A8 movw [0DFF09Ah],4000h FE92B0 addb [126h+a6],1 FE92B4 call 0FE930Eh ;@@waitvsync ;-wait, with timer b stopped ??? So, the timer wasn't stopped at all, and the counter wasn't uninitialized either. Just treating the timer as stopped with initial reset value of FFFFh worked to get through above code, although that wasn't exactly what happened on real hardware, and emulating it that way still caused problems later on (disc stepping also relies on starting/reloading the one-shot timer on MSB writes). |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Old timers dying off | Fred the Fop | Nostalgia & memories | 343 | 08 April 2022 19:29 |
Interrupts and Multitasking: Examples? | tygre | Coders. General | 13 | 22 December 2015 04:56 |
example of a CIA timer interrupt in assembler using cia.resource | Apollo | Coders. Asm / Hardware | 3 | 05 July 2013 08:40 |
Tutorial request: CIA timers | oRBIT | Coders. Tutorials | 4 | 11 June 2010 23:31 |
Advice on interrupts and jumps | alexh | Coders. General | 11 | 20 May 2008 09:42 |
|
|