Can we use the 'i' register ?

Pagina 1/2
| 2

Door Metalion

Paragon (1616)

afbeelding van Metalion

02-06-2022, 09:35

Hi everyone,

I am curious: when the Z80 is in interruption modes 0 or 1, the 'i' register has no use.
Therefore, can it be used to store values ?

ld a,i  ; ED 57 - 11 cycles
ld i,a  ; ED 47 - 11 cycles
Aangemeld of registreer om reacties te plaatsen

Van gdx

Enlighted (6004)

afbeelding van gdx

02-06-2022, 09:40

I think we can.

Van ARTRAG

Enlighted (6914)

afbeelding van ARTRAG

02-06-2022, 14:50

You can use it safely

Van Bengalack

Paladin (714)

afbeelding van Bengalack

02-06-2022, 16:28

I use it when I’m out of registers in Lilly’s Saga. I’m using im1.

Note the great feature of flags being set when doing

ld a,i 

The sign flag and zero flag is set automatically. So, for example, a 3-way conditional can be directly performed:

jp m, xxxx
jp z, yyyy
…

as other things ofc. But always take into account that this ld-command is a bit more costly than normal.

Van Metalion

Paragon (1616)

afbeelding van Metalion

02-06-2022, 20:46

Thanks everyone, that's good news.

Bengalack wrote:

The sign flag and zero flag is set automatically

Very nice !
It means that, although it's indeed costly, it's still quite competitive when performing a test:

ld  a,r  ; 5
and a    ; 5

(vs)

ld  a,i  ; 11

Van thegeps

Paragon (1156)

afbeelding van thegeps

03-06-2022, 00:34

I used it as double buffer flag on Freedom Fighter's scrolling routine

Van aoineko

Paladin (809)

afbeelding van aoineko

03-06-2022, 13:38

I made a request to have an option in SDCC for the compiler to use the I register.
You can support the request if you think it is relevant. ^^

Van hit9918

Prophet (2926)

afbeelding van hit9918

03-06-2022, 19:16

But a cool MSX OS got an IM2 interrupt server in page 3, so one can flip the slot in page 0 freely. And then the i register cannot be used.

Can you show a code that needs the i register.

And SDCC development time would better be spent on its base weakness, like seen in

p->x += p->dx;

which needs multiple registers for the addresses, when it could go in one address register (I havent checked version 4 yet).

Van ARTRAG

Enlighted (6914)

afbeelding van ARTRAG

03-06-2022, 22:29

I've just voted for you proposal, now you should vote for mine, i.e. to include support for EXX and EX in the code generation
https://sourceforge.net/p/sdcc/feature-requests/795/
;)

Van gdx

Enlighted (6004)

afbeelding van gdx

04-06-2022, 14:03

hit9918 wrote:

But a cool MSX OS got an IM2 interrupt server in page 3, so one can flip the slot in page 0 freely. And then the i register cannot be used.

You talk about SymbOS?

hit9918 wrote:

i.e. to include support for EXX and EX in the code generation

I guess they don't do this so that we can use it ourselves in our asm routines.

Van norakomi

Paragon (1134)

afbeelding van norakomi

04-06-2022, 14:52

So you would use the i register to store data if you have no other register available and you don't care about the flags ?

Pagina 1/2
| 2