gueh
This commit is contained in:
parent
2ce80a490f
commit
e5a556fe58
3 changed files with 233 additions and 7 deletions
13
aiko
13
aiko
|
@ -6,8 +6,8 @@ require_once __DIR__ . '/vendor/autoload.php';
|
|||
|
||||
error_reporting(-1);
|
||||
|
||||
define('AIKO_ROM', '/home/flash/6502_65C02_functional_tests/bin_files/6502_functional_test.bin');
|
||||
//define('AIKO_ROM', __DIR__ . '/test.bin');
|
||||
//define('AIKO_ROM', '/home/flash/6502_65C02_functional_tests/bin_files/6502_functional_test.bin');
|
||||
define('AIKO_ROM', __DIR__ . '/test.bin');
|
||||
|
||||
$cpu = new Cpu(
|
||||
FileMemory::open(AIKO_ROM)
|
||||
|
@ -28,8 +28,8 @@ $lastAddrCount = 0;
|
|||
$lastStackPtr = $cpu->state->s;
|
||||
|
||||
$cpu->state->pc = 0x400;
|
||||
printf('[ %s ]%s', $cpu->state, PHP_EOL);
|
||||
for(;;) {
|
||||
printf('[ %s ]%s', $cpu->state, PHP_EOL);
|
||||
$cpu->tick();
|
||||
|
||||
if($lastStackPtr !== $cpu->state->s) {
|
||||
|
@ -38,7 +38,7 @@ for(;;) {
|
|||
printf('Stack page:%s', PHP_EOL);
|
||||
for($i = 0; $i < 0x100; ++$i) {
|
||||
printf(' %02X', $cpu->mem->read($cpu->state->sPage | $i, true));
|
||||
if(($i % 0x10) == 0xF)
|
||||
if(($i & 0x1F) === 0x1F)
|
||||
echo PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
@ -55,5 +55,8 @@ for(;;) {
|
|||
$lastAddrCount = 0;
|
||||
}
|
||||
|
||||
usleep(200);
|
||||
printf('[ %s ]%s', $cpu->state, PHP_EOL);
|
||||
|
||||
//usleep(200);
|
||||
readline();
|
||||
}
|
||||
|
|
221
meow.s
Normal file
221
meow.s
Normal file
|
@ -0,0 +1,221 @@
|
|||
; test file for flash's lovely assembler
|
||||
; this is nonsense code
|
||||
|
||||
.org $0300
|
||||
|
||||
; ADCs
|
||||
adc ADC #40 ; 69 28
|
||||
ADC $0245 ; 6D 45 02
|
||||
ADC $35 ; 65 35
|
||||
ADC $0965,X ; 7D 05 91
|
||||
ADC $0965,Y ; 79 05 91
|
||||
ADC $45,X ; 75 45
|
||||
ADC ($45,X) ; 61 45
|
||||
ADC ($45),Y ; 71 45
|
||||
|
||||
; ANDs
|
||||
and AND #92 ; 29 92
|
||||
AND $1234 ; 2D 34 12
|
||||
AND $36 ; 25 36
|
||||
AND $2345,X ; 3D 45 23
|
||||
AND $3456,Y ; 39 56 34
|
||||
AND $45,X ; 35 45
|
||||
AND ($56,X) ; 21 56
|
||||
AND ($67),Y ; 31 67
|
||||
|
||||
; ASLs
|
||||
asl ASL A ; 0A
|
||||
ASL $9876 ; 0E 76 98
|
||||
ASL $54 ; 06 54
|
||||
ASL $2938,X ; 1E 38 29
|
||||
ASL $55,X ; 16 55
|
||||
|
||||
; Branches
|
||||
bcc BCC asl ; 90 xx
|
||||
bcs BCS asl ; B0 xx
|
||||
beq BEQ asl ; F0 xx
|
||||
bmi BMI asl ; 30 xx
|
||||
bne BNE asl ; D0 xx
|
||||
bpl BPL asl ; 10 xx
|
||||
bvc BVC asl ; 50 xx
|
||||
bvs BVS asl ; 70 xx
|
||||
|
||||
; Test Memory Bits
|
||||
bit BIT $6502 ; 2C 02 65
|
||||
BIT $67 ; 24 67
|
||||
|
||||
; Software Break
|
||||
brk BRK ; 00 00
|
||||
BRK #$40 ; 00 40
|
||||
|
||||
; Clear flags
|
||||
clc CLC ; 18
|
||||
cld CLD ; D8
|
||||
cli CLI ; 58
|
||||
clv CLV ; B8
|
||||
|
||||
; Compare
|
||||
cmp CMP #67 ; C9 43
|
||||
CMP $5432 ; CD 32 54
|
||||
CMP $98 ; C5 98
|
||||
CMP $4466,X ; DD 66 44
|
||||
CMP $5577,Y ; D9 77 55
|
||||
CMP $33,X ; D5 33
|
||||
CMP ($22,X) ; C1 22
|
||||
CMP ($11),Y ; D1 11
|
||||
|
||||
; Compare with X
|
||||
cpx CPX #$12 ; E0 12
|
||||
CPX $8086 ; EC 86 80
|
||||
CPX $44 ; E4 44
|
||||
|
||||
; Compare with Y
|
||||
cpy CPY #$95 ; C0 95
|
||||
CPY $4334 ; CC 34 43
|
||||
CPY $C4 ; C4 C4
|
||||
|
||||
; Decrement
|
||||
dec DEC $0987 ; CE 87 09
|
||||
DEC $08 ; C6 08
|
||||
DEC $0765,X ; DE 65 07
|
||||
DEC 128,X ; D6 80
|
||||
|
||||
; Decrement X
|
||||
dex DEX ; CA
|
||||
|
||||
; Decrement Y
|
||||
dey DEY ; 88
|
||||
|
||||
; XOR
|
||||
eor EOR #$65 ; 49 65
|
||||
EOR $2330 ; 4D 30 23
|
||||
EOR $43 ; 45 43
|
||||
EOR $5544,X ; 5D 44 55
|
||||
EOR $4433,Y ; 59 33 44
|
||||
EOR $66,X ; 55 66
|
||||
EOR ($44,X) ; 41 44
|
||||
EOR ($45),Y ; 51 45
|
||||
|
||||
; Increment
|
||||
inc INC 31234 ; EE 02 7A
|
||||
INC 60 ; E6 3C
|
||||
INC $5040,X ; FE 40 50
|
||||
INC $60,X ; F6 60
|
||||
|
||||
; Increment X
|
||||
inx INX ; E8
|
||||
|
||||
; Increment Y
|
||||
iny INY ; C8
|
||||
|
||||
; Jump!
|
||||
jmp JMP 65535 ; 4C FF FF
|
||||
JMP (43605) ; 6C 55 AA
|
||||
|
||||
; Jump! to subroutine
|
||||
jsr JSR $0200 ; 20 00 02
|
||||
|
||||
; Load A
|
||||
lda LDA #$55 ; A9 55
|
||||
LDA $6789 ; AD 89 67
|
||||
LDA $34 ; A5 34
|
||||
LDA $5634,X ; BD 34 56
|
||||
LDA $2345,Y ; B9 45 23
|
||||
LDA $54,X ; B5 54
|
||||
LDA ($12,X) ; A1 12
|
||||
LDA ($31),Y ; B1 31
|
||||
|
||||
; Load X
|
||||
ldx LDX #255 ; A2 FF
|
||||
LDX $6699 ; AE 99 66
|
||||
LDX $96 ; A6 96
|
||||
LDX $9669,Y ; BE 69 96
|
||||
LDX $69,Y ; B9 69
|
||||
|
||||
; Load Y
|
||||
ldy LDY #0 ; A0 00
|
||||
LDY $1122 ; AC 22 11
|
||||
LDY $33 ; A4 33
|
||||
LDY $4455,x ; BC 55 44
|
||||
LDY $66,x ; B4 66
|
||||
|
||||
; Logical shift right
|
||||
lsr LSR A ; 4A
|
||||
LSR 10009 ; 4E 19 27
|
||||
LSR 176 ; 46 B0
|
||||
LSR 20010,x ; 5E 2A 4E
|
||||
LSR 200,x ; 56 C8
|
||||
|
||||
; No-op
|
||||
nop NOP ; EA
|
||||
|
||||
; OR
|
||||
ora ORA #$55 ; 09 55
|
||||
ORA $6770 ; 0D 70 67
|
||||
ORA $23 ; 05 23
|
||||
ORA $2552,X ; 1D 52 25
|
||||
OrA $5225,Y ; 19 25 52
|
||||
ORA $12,X ; 15 12
|
||||
ORA ($23,X) ; 01 23
|
||||
ORA ($34),Y ; 11 34
|
||||
|
||||
; Push onto stack
|
||||
pha PHA ; 48
|
||||
php PHP ; 08
|
||||
|
||||
; Pull from stack
|
||||
pla PLA ; 68
|
||||
plp PLP ; 28
|
||||
|
||||
; Rotate left
|
||||
rol ROL A ; 2A
|
||||
ROL $1234 ; 2E 34 12
|
||||
ROL $56 ; 26 56
|
||||
rol $7890,X ; 3E 90 78
|
||||
rol $12,x ; 36 12
|
||||
|
||||
; Rotate right
|
||||
ror ROR A ; 6A
|
||||
ROR $5434 ; 6E 34 54
|
||||
ROR $45 ; 66 45
|
||||
ROR $6545,X ; 7E 45 65
|
||||
ROR $12,X ; 76 12
|
||||
|
||||
; Return from interrupt
|
||||
rti RTI ; 40
|
||||
|
||||
; Return form subroutine
|
||||
rts RTS ; 60
|
||||
|
||||
; Set flags
|
||||
sec SEC ; 38
|
||||
sed SED ; F8
|
||||
sei SEI ; 78
|
||||
|
||||
; Store A
|
||||
sta STA $4554 ; 8D 54 45
|
||||
STA $65 ; 85 65
|
||||
STA $3443,X ; 9D 43 34
|
||||
STA $1221,Y ; 99 21 12
|
||||
STA $65,X ; 95 65
|
||||
STA ($34,X) ; 81 34
|
||||
STA ($45),Y ; 91 45
|
||||
|
||||
; Store X
|
||||
stx STX $1234 ; 8E 34 12
|
||||
STX $21 ; 86 21
|
||||
STX $98,Y ; 96 98
|
||||
|
||||
; Store Y
|
||||
sty STY $4321 ; 8C 21 43
|
||||
STY $65 ; 84 65
|
||||
STY $87,X ; 94 87
|
||||
|
||||
; Transfers
|
||||
tax TAX ; AA
|
||||
tay TAY ; A8
|
||||
tsx TSX ; BA
|
||||
txa TXA ; 8A
|
||||
txs TXS ; 9A
|
||||
; 98
|
||||
tya TYA
|
|
@ -39,14 +39,16 @@ class FileMemory implements Memory {
|
|||
}
|
||||
}
|
||||
|
||||
/** @throws UnexpectedValueException if $readFunc is outside of the expected range. */
|
||||
/** @throws InvalidArgumentException if $readFunc is outside of the expected range. */
|
||||
public function read(int $addr, bool $silent = false): int {
|
||||
if($addr < 0 || $addr > 0xFFFF)
|
||||
throw new InvalidArgumentException('$addr is out of range');
|
||||
|
||||
fseek($this->file, $addr);
|
||||
|
||||
$char = fgetc($this->file);
|
||||
if($char === false)
|
||||
throw new UnexpectedValueException('failed to read offset');
|
||||
return 0;
|
||||
|
||||
if(!$silent)
|
||||
printf('R $%04X -> $%02X%s', $addr, ord($char), PHP_EOL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue