Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with IN and OUT instructions to support the upper byte of the address #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abelykh0
Copy link

I was testing Sinclair emulator and realized that BREAK in BASIC didn't work. My changes fix this.

Their code for BREAK is like this:
1F54 BREAK-KEY
LD A,+7F Form the port address
IN A,(+FE) +7FFE and read in a byte.
RRA Examine only bit 0 by shifting
it into the carry position.
RET C Return if the BREAK key is
not being pressed.
LD A,+FE Form the port address
IN A,(+FE) +FEFE and read in a byte.
RRA Again examine bit 0.
RET Return with carry reset if
both keys are being pressed.

@anotherlin
Copy link
Owner

Hi Andrey,

Thank you for reporting and fixing that bug.
I totally missed the fact that the port address may be 16-bit.
My targeted device (Sega Master System) makes only use of 8-bit.
I've double checked the Z80 User's manual.
And the output instructions will also need to be fixed as the upper 8-bit of the address is also relevant.
I'll work on that.

Best regards,

@abelykh0 abelykh0 changed the title Fixed issue with IN A,(N) instruction Fixed issue with IN and OUT instructions to support the upper byte of the address Jun 12, 2019
@leighbb
Copy link

leighbb commented Jun 20, 2019

@abelykh0 @anotherlin
I think it would better to simply specify the port as a 16-bit value in the Z80_INPUT_BYTE and Z80_OUTPUT_BYTE macros. Also, we should update the documentation for those macros in
z80user.h.

I have created a branch in my fork with those proposed changes. I'm not sure the best way to
reference them, so here is a link to the branch:

leighbb/z80emu 16_bit_port branch

I'm not an expert on github but I can send a patch or create a separate pull request if you like this approach.

Cheers,

Leigh.

@abelykh0
Copy link
Author

That's fine with me. Whatever seems more logical to @anotherlin.

@anotherlin
Copy link
Owner

anotherlin commented Jun 20, 2019 via email

@abelykh0 abelykh0 force-pushed the master branch 3 times, most recently from afdf832 to 5e6d78d Compare November 24, 2024 00:20
Fixed IN and OUT instructions to support the upper byte of the address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants