Retrochallenge 2017/4 – Interak CF card – Part 4

We are well into the second half of Retrochallenge now and it fair to say that I’m not where I wanted to be. However I am learning a great deal about Z80s and CF cards are their respective wily ways.
Things continue to be confusing.
A quick re-cap of my previous posts…
It started off with the status of the CF card never showing that the read transfer was ready. However, using the ROM monitor on the Interak rather than the program showed that it was. There were various trials and hair being pulled out but what it boils down to is this.
If I use…

    ld        BC, (0x0067)
    in        a, (C)

I get one value but if I use…

    ld        a, 0x00
    in        a, (0x67)

I get a different answer.
Note 0x67 is the CF card status port.
According to the Z80 manual from Zilog, in a, (C), puts B on to the top of the address bus, C on to the bottom and reads from the addressed I/O port. So that’s 0x0067.
Now, in a, 0x67, puts A on to the top of the bus (previously loaded with 0) and 0x67 on to the bottom and reads the addressed I/O port.
These two are functionally the same but give different results.
One suggestion that has been made though the VCfed forums is that it’s a timing issue as the in a, (C) version takes a little longer.
I have a few things to try. I have a couple of other CF cards on order and they should arrive soon. I’ll try them to see if there is some issue with the timing of this card. I’ll also look to see if I can get a wait state in to the IN operation.
More news when I have it.

2 thoughts on “Retrochallenge 2017/4 – Interak CF card – Part 4”

  1. Hi Andy
    Firstly you have a great website – a lot more user friendly than the Interak site. I have not updated it for ages……

    Just a note about your Z80 code above which looks a bit strange to me. Sorry if some of the following is obvious.

    The instruction LD BC,(1234H)
    will load regidter BC with the data at location 1234H,
    whereas LD BC,1234H (with no brackets) will load BC with the data 1234H

    so if you want to load the Accumulator with the data at Port 67H
    you can use IN A,(67H)

    or LD C,67H
    IN A,(C)

    or LD BC,0067H
    IN A,(C) which is the same

    with the Z80 – available Ports are 00 to FFH (0-255)
    0000 0000 – 1111 1111

    Compact Flash drives require a set of 8 continuous registers, as they only use A0, A1 and A2 for register addressing. So your base address could be 40H, 50H, 60H etc
    In the case of base address 60H registers 60H, 61H, etc to 6FH would be used.

    The assembler I use assumes decimal numbers – to denote Hex the number has have H, or B for binary.

    Hope that this is helpful, Alan

    1. Thanks so much for that Alan,

      My 30 year old Z80 knowledge has let me down. Of crouse, you are dead right, brackets mean indirection.

      I can’t believe I missed that. 😉

      I’ll try again and see what happens.

      Thanks again,


Leave a Reply

Your email address will not be published. Required fields are marked *