mirror of
https://github.com/felipecsl/6502Android.git
synced 2025-01-04 14:33:00 +00:00
Adds more tests
This commit is contained in:
parent
a7769ba7f0
commit
b793402c90
@ -234,7 +234,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
||||
val finalParam = param.replace(",Y", "", true).replace(",X", "", true)
|
||||
pushByte(opcode)
|
||||
val addr = labels.get(finalParam)
|
||||
if (addr != null) {
|
||||
if (addr != -1) {
|
||||
if (addr < 0 || addr > 0xffff) {
|
||||
return false
|
||||
}
|
||||
@ -259,7 +259,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
||||
if (opcode == 0xff) {
|
||||
return false
|
||||
}
|
||||
return checkByteOperand(param, opcode, "^\\(([\\w\\$]+)\\),X$")
|
||||
return checkByteOperand(param, opcode, "^\\(([\\w\\$]+),X\\)$")
|
||||
}
|
||||
|
||||
private fun checkIndirect(param: String, opcode: Int): Boolean {
|
||||
@ -320,7 +320,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
||||
var hilo = param.replace("^#([<>]).*$".toRegex(), "$1")
|
||||
pushByte(opcode)
|
||||
val addr = labels.get(label)
|
||||
if (addr != null) {
|
||||
if (addr != -1) {
|
||||
when (hilo) {
|
||||
">" -> {
|
||||
pushByte(addr.shr(8).and(0xFF))
|
||||
|
@ -82,7 +82,7 @@ public class AssemblerTest {
|
||||
assertThat(assembler.hexdump(), equalTo("0600: A9 01 85 F0 A9 CC 85 F1 6C F0 00"));
|
||||
}
|
||||
|
||||
@Test public void testIndexedIndirect() {
|
||||
@Test public void testIndirectX() {
|
||||
List<String> lines = ImmutableList.of(
|
||||
"LDX #$01",
|
||||
"LDA #$05",
|
||||
@ -97,4 +97,34 @@ public class AssemblerTest {
|
||||
assertThat(assembler.hexdump(),
|
||||
equalTo("0600: A2 01 A9 05 85 01 A9 06 85 02 A0 0A 8C 05 06 A1 \n0610: 00"));
|
||||
}
|
||||
|
||||
@Test public void testIndirectY() {
|
||||
List<String> lines = ImmutableList.of(
|
||||
"LDY #$01",
|
||||
"LDA #$03",
|
||||
"STA $01",
|
||||
"LDA #$07",
|
||||
"STA $02",
|
||||
"LDX #$0a",
|
||||
"STX $0704",
|
||||
"LDA ($01),Y");
|
||||
|
||||
assembler.assembleCode(lines);
|
||||
assertThat(assembler.hexdump(),
|
||||
equalTo("0600: A0 01 A9 03 85 01 A9 07 85 02 A2 0A 8E 04 07 B1 \n0610: 01"));
|
||||
}
|
||||
|
||||
@Test public void testJump() {
|
||||
List<String> lines = ImmutableList.of(
|
||||
"LDA #$03",
|
||||
"JMP there",
|
||||
"BRK",
|
||||
"BRK",
|
||||
"BRK",
|
||||
"there:",
|
||||
"STA $0200");
|
||||
|
||||
assembler.assembleCode(lines);
|
||||
assertThat(assembler.hexdump(), equalTo("0600: A9 03 4C 08 06 00 00 00 8D 00 02"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user