-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from suzukiplan/1.9.0
Modify the timing of decrementing the B register with the repeat I/O operands
- Loading branch information
Showing
7 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "z80.hpp" | ||
|
||
int main() | ||
{ | ||
unsigned char rom[256] = { | ||
0x01, 0x10, 0x03, // LD BC, $0310 | ||
0xED, 0xA2, // INI | ||
0x01, 0x20, 0x02, // LD BC, $0220 | ||
0xED, 0xB2, // INIR | ||
0x01, 0x30, 0x03, // LD BC, $0330 | ||
0xED, 0xAA, // IND | ||
0x01, 0x40, 0x02, // LD BC, $0240 | ||
0xED, 0xBA, // INDR | ||
0x01, 0x50, 0x03, // LD BC, $0350 | ||
0xED, 0xA3, // OUTI | ||
0x01, 0x60, 0x02, // LD BC, $0260 | ||
0xED, 0xB3, // OTIR | ||
0x01, 0x70, 0x03, // LD BC, $0370 | ||
0xED, 0xAB, // OUTD | ||
0x01, 0x80, 0x02, // LD BC, $0280 | ||
0xED, 0xBB, // OTDR | ||
}; | ||
unsigned short expectPorts[] = { | ||
0x0210, | ||
0x0120, | ||
0x0020, | ||
0x0230, | ||
0x0140, | ||
0x0040, | ||
0x0250, | ||
0x0160, | ||
0x0060, | ||
0x0270, | ||
0x0180, | ||
0x0080, | ||
}; | ||
int expectPortIndex = 0; | ||
Z80 z80([&rom](void* arg, unsigned short addr) { | ||
return rom[addr & 0xFF]; | ||
}, [](void* arg, unsigned char addr, unsigned char value) { | ||
// nothing to do | ||
}, [&](void* arg, unsigned short port) { | ||
printf("IN port A <- $%04X\n", | ||
port // the full (A0 through A15) of the address bus to select the I/O device at one of 65536 possible ports | ||
); | ||
if (port != expectPorts[expectPortIndex++]) { | ||
puts("UNEXPECTED!"); | ||
exit(-1); | ||
} | ||
return 0; | ||
}, [](void* arg, unsigned short port, unsigned char value) { | ||
printf("OUT port $%04X <- $%02X\n", | ||
port, // the full (A0 through A15) of the address bus to select the I/O device at one of 65536 possible ports | ||
value | ||
); | ||
}, &z80, true); | ||
z80.setDebugMessage([](void* arg, const char* msg) { puts(msg); }); | ||
z80.addBreakOperand(0x00, [](void* arg, unsigned char* operands, int size) { | ||
exit(0); | ||
}); | ||
z80.execute(INT_MAX); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[0000] LD BC<$0000>, $0310 | ||
IN port A <- $0210 | ||
[0003] INI ... (HL<$0000>) <- p(C<$10>) = $00 [B<$02>] | ||
[0005] LD BC<$0210>, $0220 | ||
IN port A <- $0120 | ||
[0008] INIR ... (HL<$0001>) <- p(C<$20>) = $00 [B<$01>] | ||
IN port A <- $0020 | ||
[0008] INIR ... (HL<$0002>) <- p(C<$20>) = $00 [B<$00>] | ||
[000A] LD BC<$0020>, $0330 | ||
IN port A <- $0230 | ||
[000D] IND ... (HL<$0003>) <- p(C<$30>) = $00 [B<$02>] | ||
[000F] LD BC<$0230>, $0240 | ||
IN port A <- $0140 | ||
[0012] INDR ... (HL<$0002>) <- p(C<$40>) = $00 [B<$01>] | ||
IN port A <- $0040 | ||
[0012] INDR ... (HL<$0001>) <- p(C<$40>) = $00 [B<$00>] | ||
[0014] LD BC<$0040>, $0350 | ||
[0017] OUTI ... p(C<$50>) <- (HL<$0000>) <$01> [B<$03>] | ||
OUT port $0250 <- $01 | ||
[0019] LD BC<$0250>, $0260 | ||
[001C] OUTIR ... p(C<$60>) <- (HL<$0001>) <$10> [B<$02>] | ||
OUT port $0160 <- $10 | ||
[001C] OUTIR ... p(C<$60>) <- (HL<$0002>) <$03> [B<$01>] | ||
OUT port $0060 <- $03 | ||
[001E] LD BC<$0060>, $0370 | ||
[0021] OUTD ... p(C<$70>) <- (HL<$0003>) <$ed> [B<$03>] | ||
OUT port $0270 <- $ED | ||
[0023] LD BC<$0270>, $0280 | ||
[0026] OUTDR ... p(C<$80>) <- (HL<$0002>) <$03> [B<$02>] | ||
OUT port $0180 <- $03 | ||
[0026] OUTDR ... p(C<$80>) <- (HL<$0001>) <$10> [B<$01>] | ||
OUT port $0080 <- $10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters