Karoshi MSX Community

Desarrollo MSX => Development (English/Ingles) => Mensaje iniciado por: Dioniso en 20 de Enero de 2009, 06:34:58 pm



Título: IM2
Publicado por: Dioniso en 20 de Enero de 2009, 06:34:58 pm
   Hi!

   I have been doing some testing with the IM2 mode, which is something completely new to me.

   The setting up I have goes like this:

Código:
di
ld hl,TABLE257
ld bc,MAIN
ld (hl),b
inc hl
ld (hl),c
ld e,l
ld d,h
inc de
dec hl
ld bc,$ff
ldir
ld a,$d0
ld i,a
im 2

Where TABLE257 is a space in RAM to store the higher byte of the routine MAIN. The space is stored at $D000.

Since this is unknown to me, I have some questions for the experts in IM2:

-Is that routine above correct?
-Is the frame rate still 50/60hz or it depends on the use of HALT?
-After every HALT is the routine MAIN called automatically?

I think the routine above is not completely right...

I already had a look at the one in the SNIPPETS, by jltursan, but there are some things I still don't understand quite well...

I am doing the testings on BlueMSX.


Título: Re: IM2
Publicado por: SapphiRe_MSX en 20 de Enero de 2009, 07:05:34 pm
The main problem with IM2 mode is that the routine you want to jump in should have the same upper and lower byte. So there's only 256 possible locations for this routine. When an interrupt occurs:

-Register I contains the upper byte of the address with the direction of the routine (you can control this)
-Data on the bus contains the lower byte of the address with the direction of the routine (you can't control this)
-CPU looks on the direction and jumps to this address

That's why you need to put the routine in an address with the same upper and lower byte.

Citar
-Is that routine above correct?

No. First you have to place your routine in a valid address and fill the table with that byte.

Citar
-Is the frame rate still 50/60hz or it depends on the use of HALT?

Is independent and controlled by the VDP, as usual.

Citar
-After every HALT is the routine MAIN called automatically?

If you put the routine in a valid address, init the I register with the upper byte of the 257 byte table and fill the table with the correct value: yes.

Regards
--
Sph.


Título: Re: IM2
Publicado por: Dioniso en 20 de Enero de 2009, 07:10:35 pm
The main problem with IM2 mode is that the routine you want to jump in should have the same upper and lower byte. So there's only 256 possible locations for this routine.

Mmm... I thought we could control the higher byte, not the lower, that's why we have to fill the 256 possibilities, just for the lower byte...

So I'll try what you say, SapphiRe. Thanks again!  ;)


Título: Re: IM2
Publicado por: SapphiRe_MSX en 20 de Enero de 2009, 07:30:26 pm
Mmm... I thought we could control the higher byte, not the lower, that's why we have to fill the 256 possibilities, just for the lower byte...

Yes, you can control the higher byte of the address of the table, not the lower. So, for instance, if the table is located on $D000, register I should be initialized to $D0 and:

a) If bus has $88, the address of the interrupt routine is located at $D088
b) If bus has $89, the address of the interrupt routine is located at $D089

As you want to jump to the same routine, $D088 and $D089 must have the same byte (lower byte of the address). That's why the interrupt routine must be placed on an address with the same upper and lower byte.


Título: Re: IM2
Publicado por: Dioniso en 20 de Enero de 2009, 09:00:23 pm
I surrender. Bye.


Título: Re: IM2
Publicado por: Dioniso en 21 de Enero de 2009, 07:32:19 pm
Thanks again, SapphiRe, for your help. Your private messages helped me to understand how IM2 works  :D


Título: Re: IM2
Publicado por: k0ga en 13 de Febrero de 2009, 09:52:07 am
The main problem with IM2 mode is that the routine you want to jump in should have the same upper and lower byte. So there's only 256 possible locations for this routine. When an interrupt occurs:

-Register I contains the upper byte of the address with the direction of the routine (you can control this)
-Data on the bus contains the lower byte of the address with the direction of the routine (you can't control this)
-CPU looks on the direction and jumps to this address

That's why you need to put the routine in an address with the same upper and lower byte.


How in MSX wasn't fixed address read in the bus, in theory you could read any value, but in real life I can sure you that you will read always a FF, because is a hardware basic design rule (put pullup resistor in the bus to avoid fluctuations which can cause problems).


Título: Re: IM2
Publicado por: Dioniso en 13 de Febrero de 2009, 01:52:10 pm
I read somewhere some computers doesn't read $ff. I think it was a Brazilian computer.