Initial PPC emulation tests.

This commit is contained in:
Maxim Poliakovski 2020-01-31 04:10:53 +01:00
parent 29fa6e6174
commit 7d7b0b7de3
5 changed files with 15132 additions and 0 deletions

View File

@ -14,5 +14,12 @@ file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/*.cpp" "${PROJECT_SOURCE_DIR}/devices/*
"${PROJECT_SOURCE_DIR}/debugger/*.cpp"
"${PROJECT_SOURCE_DIR}/cpu/ppc/*.cpp")
file(GLOB TEST_SOURCES "${PROJECT_SOURCE_DIR}/cpu/ppc/*.cpp"
"${PROJECT_SOURCE_DIR}/devices/*.cpp"
"${PROJECT_SOURCE_DIR}/cpu/ppc/test/*.cpp")
add_executable(dingusppc ${SOURCES})
add_executable(testppc ${TEST_SOURCES})
install (TARGETS dingusppc DESTINATION ${EXECUTABLE_OUTPUT_PATH})

106
cpu/ppc/test/genppctests.py Normal file
View File

@ -0,0 +1,106 @@
def gen_ppc_opcode(opc_str, imm):
if opc_str == "ADD":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x10A << 1)
elif opc_str == "ADD.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x10A << 1) + 1
elif opc_str == "ADDC":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0xA << 1)
elif opc_str == "ADDC.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0xA << 1) + 1
elif opc_str == "ADDCO":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x20A << 1)
elif opc_str == "ADDCO.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x20A << 1) + 1
elif opc_str == "ADDO":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x30A << 1)
elif opc_str == "ADDO.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x30A << 1) + 1
elif opc_str == "ADDE":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x8A << 1)
elif opc_str == "ADDE.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x8A << 1) + 1
elif opc_str == "ADDEO":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x28A << 1)
elif opc_str == "ADDEO.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (4 << 11) + (0x28A << 1) + 1
elif opc_str == "ADDI":
return (0x0E << 26) + (3 << 21) + (3 << 16) + (imm & 0xFFFF)
elif opc_str == "ADDIC":
return (0x0C << 26) + (3 << 21) + (3 << 16) + (imm & 0xFFFF)
elif opc_str == "ADDIS":
return (0x0F << 26) + (3 << 21) + (3 << 16) + (imm & 0xFFFF)
elif opc_str == "ADDME":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0xEA << 1)
elif opc_str == "ADDME.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0xEA << 1) + 1
elif opc_str == "ADDMEO":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0x2EA << 1)
elif opc_str == "ADDMEO.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0x2EA << 1) + 1
elif opc_str == "ADDZE":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0xCA << 1)
elif opc_str == "ADDZE.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0xCA << 1) + 1
elif opc_str == "ADDZEO":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0x2CA << 1)
elif opc_str == "ADDZEO.":
return (0x1F << 26) + (3 << 21) + (3 << 16) + (0x2CA << 1) + 1
def find_imm(line):
pos = 12
while pos < len(line):
reg_id = line[pos:pos+4]
if reg_id.startswith("rD") or reg_id.startswith("rA") or reg_id.startswith("rB"):
pos += 16
elif reg_id.startswith("XER:"):
pos += 18
elif reg_id.startswith("CR:"):
pos += 17
elif reg_id.startswith("imm"):
return int(line[pos+4:pos+14], base=16)
return 0
with open("instruction_tests_console.txt", "r") as in_file:
with open("ppcinttests.csv", "w") as out_file:
lineno = 0
for line in in_file:
line = line.strip()
opcode = (line[0:8]).rstrip()
out_file.write(opcode + ",")
imm = find_imm(line)
out_file.write("0x{:X}".format(gen_ppc_opcode(opcode, imm)))
pos = 12
while pos < len(line):
reg_id = line[pos:pos+4]
if reg_id.startswith("rD"):
out_file.write(",rD=" + line[pos+3:pos+13])
pos += 16
elif reg_id.startswith("rA"):
out_file.write(",rA=" + line[pos+3:pos+13])
pos += 16
elif reg_id.startswith("rB"):
out_file.write(",rB=" + line[pos+3:pos+13])
pos += 16
elif reg_id.startswith("XER:"):
out_file.write(",XER=" + line[pos+5:pos+15])
pos += 18
elif reg_id.startswith("CR:"):
out_file.write(",CR=" + line[pos+4:pos+14])
pos += 17
elif reg_id.startswith("imm"):
pos += 17 # ignore immediate operands
else:
out_file.write("Unknown reg ID" + reg_id)
break
out_file.write("\n")
lineno += 1
if lineno > 152:
break

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,153 @@
ADD,0x7C632214,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADD,0x7C632214,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADD.,0x7C632215,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADD.,0x7C632215,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADD.,0x7C632215,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x20000000
ADD.,0x7C632215,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x20000000
ADD.,0x7C632215,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADD.,0x7C632215,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADD.,0x7C632215,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDC,0x7C632014,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDC,0x7C632014,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDC,0x7C632014,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDC,0x7C632014,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDC,0x7C632014,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDC,0x7C632014,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADDC,0x7C632014,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDC.,0x7C632015,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDC.,0x7C632015,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDC.,0x7C632015,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDC.,0x7C632015,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDC.,0x7C632015,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDC.,0x7C632015,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADDC.,0x7C632015,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDCO,0x7C632414,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x00000000
ADDCO,0x7C632414,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDCO,0x7C632414,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDCO,0x7C632414,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDCO,0x7C632414,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDCO,0x7C632414,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADDCO,0x7C632414,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDCO.,0x7C632415,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x90000000
ADDCO.,0x7C632415,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDCO.,0x7C632415,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDCO.,0x7C632415,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDCO.,0x7C632415,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDCO.,0x7C632415,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADDCO.,0x7C632415,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDO,0x7C632614,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x00000000
ADDO,0x7C632614,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDO,0x7C632614,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDO,0x7C632614,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDO,0x7C632614,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDO,0x7C632614,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADDO,0x7C632614,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDO.,0x7C632615,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x90000000
ADDO.,0x7C632615,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDO.,0x7C632615,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x20000000
ADDO.,0x7C632615,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x20000000
ADDO.,0x7C632615,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDO.,0x7C632615,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADDO.,0x7C632615,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDE,0x7C632114,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDE,0x7C632114,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDE,0x7C632114,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDE,0x7C632114,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDE,0x7C632114,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDE,0x7C632114,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADDE,0x7C632114,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDE.,0x7C632115,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDE.,0x7C632115,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDE.,0x7C632115,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDE.,0x7C632115,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDE.,0x7C632115,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDE.,0x7C632115,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADDE.,0x7C632115,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDEO,0x7C632514,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x00000000
ADDEO,0x7C632514,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x00000000
ADDEO,0x7C632514,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDEO,0x7C632514,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x00000000
ADDEO,0x7C632514,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDEO,0x7C632514,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x00000000
ADDEO,0x7C632514,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDEO.,0x7C632515,rD=0x80000000,rA=0x7FFFFFFF,rB=0x00000001,XER=0xC0000000,CR=0x90000000
ADDEO.,0x7C632515,rD=0x80000001,rA=0x80000000,rB=0x00000001,XER=0x00000000,CR=0x80000000
ADDEO.,0x7C632515,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDEO.,0x7C632515,rD=0x00000000,rA=0xFFFFFFFF,rB=0x00000001,XER=0x20000000,CR=0x20000000
ADDEO.,0x7C632515,rD=0xFFFFFFFE,rA=0xFFFFFFFF,rB=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDEO.,0x7C632515,rD=0x00000001,rA=0x00000001,rB=0x00000000,XER=0x00000000,CR=0x40000000
ADDEO.,0x7C632515,rD=0xFFFFFFFF,rA=0x00000000,rB=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDI,0x38630001,rD=0x80000000,rA=0x7FFFFFFF,XER=0x00000000,CR=0x00000000
ADDI,0x38630001,rD=0x80000001,rA=0x80000000,XER=0x00000000,CR=0x00000000
ADDI,0x38630001,rD=0x00000000,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDI,0x38630001,rD=0x00000000,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDI,0x3863FFFF,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDI,0x38630000,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x00000000
ADDI,0x3863FFFF,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDIC,0x30630001,rD=0x80000000,rA=0x7FFFFFFF,XER=0x00000000,CR=0x00000000
ADDIC,0x30630001,rD=0x80000001,rA=0x80000000,XER=0x00000000,CR=0x00000000
ADDIC,0x30630001,rD=0x00000000,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDIC,0x30630001,rD=0x00000000,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDIC,0x3063FFFF,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDIC,0x30630000,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x00000000
ADDIC,0x3063FFFF,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDIS,0x3C630001,rD=0x8000FFFF,rA=0x7FFFFFFF,XER=0x00000000,CR=0x00000000
ADDIS,0x3C630001,rD=0x80010000,rA=0x80000000,XER=0x00000000,CR=0x00000000
ADDIS,0x3C630001,rD=0x0000FFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDIS,0x3C630001,rD=0x0000FFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDIS,0x3C63FFFF,rD=0xFFFEFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDIS,0x3C630000,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x00000000
ADDIS,0x3C63FFFF,rD=0xFFFF0000,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0x7FFFFFFE,rA=0x7FFFFFFF,XER=0x20000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0x7FFFFFFF,rA=0x80000000,XER=0x20000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0x00000000,rA=0x00000001,XER=0x20000000,CR=0x00000000
ADDME,0x7C6301D4,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDME.,0x7C6301D5,rD=0x7FFFFFFE,rA=0x7FFFFFFF,XER=0x20000000,CR=0x40000000
ADDME.,0x7C6301D5,rD=0x7FFFFFFF,rA=0x80000000,XER=0x20000000,CR=0x40000000
ADDME.,0x7C6301D5,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDME.,0x7C6301D5,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDME.,0x7C6301D5,rD=0x00000000,rA=0x00000001,XER=0x20000000,CR=0x20000000
ADDME.,0x7C6301D5,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x80000000
ADDMEO,0x7C6305D4,rD=0x7FFFFFFE,rA=0x7FFFFFFF,XER=0x20000000,CR=0x00000000
ADDMEO,0x7C6305D4,rD=0x7FFFFFFF,rA=0x80000000,XER=0xE0000000,CR=0x00000000
ADDMEO,0x7C6305D4,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDMEO,0x7C6305D4,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x00000000
ADDMEO,0x7C6305D4,rD=0x00000000,rA=0x00000001,XER=0x20000000,CR=0x00000000
ADDMEO,0x7C6305D4,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDMEO.,0x7C6305D5,rD=0x7FFFFFFE,rA=0x7FFFFFFF,XER=0x20000000,CR=0x40000000
ADDMEO.,0x7C6305D5,rD=0x7FFFFFFF,rA=0x80000000,XER=0xE0000000,CR=0x50000000
ADDMEO.,0x7C6305D5,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDMEO.,0x7C6305D5,rD=0xFFFFFFFE,rA=0xFFFFFFFF,XER=0x20000000,CR=0x80000000
ADDMEO.,0x7C6305D5,rD=0x00000000,rA=0x00000001,XER=0x20000000,CR=0x20000000
ADDMEO.,0x7C6305D5,rD=0xFFFFFFFF,rA=0x00000000,XER=0x00000000,CR=0x80000000
ADDZE,0x7C630194,rD=0x7FFFFFFF,rA=0x7FFFFFFF,XER=0x00000000,CR=0x00000000
ADDZE,0x7C630194,rD=0x80000000,rA=0x80000000,XER=0x00000000,CR=0x00000000
ADDZE,0x7C630194,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDZE,0x7C630194,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDZE,0x7C630194,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x00000000
ADDZE,0x7C630194,rD=0x00000000,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDZE.,0x7C630195,rD=0x7FFFFFFF,rA=0x7FFFFFFF,XER=0x00000000,CR=0x40000000
ADDZE.,0x7C630195,rD=0x80000000,rA=0x80000000,XER=0x00000000,CR=0x80000000
ADDZE.,0x7C630195,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDZE.,0x7C630195,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDZE.,0x7C630195,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x40000000
ADDZE.,0x7C630195,rD=0x00000000,rA=0x00000000,XER=0x00000000,CR=0x20000000
ADDZEO,0x7C630594,rD=0x7FFFFFFF,rA=0x7FFFFFFF,XER=0x00000000,CR=0x00000000
ADDZEO,0x7C630594,rD=0x80000000,rA=0x80000000,XER=0x00000000,CR=0x00000000
ADDZEO,0x7C630594,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDZEO,0x7C630594,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x00000000
ADDZEO,0x7C630594,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x00000000
ADDZEO,0x7C630594,rD=0x00000000,rA=0x00000000,XER=0x00000000,CR=0x00000000
ADDZEO.,0x7C630595,rD=0x7FFFFFFF,rA=0x7FFFFFFF,XER=0x00000000,CR=0x40000000
ADDZEO.,0x7C630595,rD=0x80000000,rA=0x80000000,XER=0x00000000,CR=0x80000000
ADDZEO.,0x7C630595,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDZEO.,0x7C630595,rD=0xFFFFFFFF,rA=0xFFFFFFFF,XER=0x00000000,CR=0x80000000
ADDZEO.,0x7C630595,rD=0x00000001,rA=0x00000001,XER=0x00000000,CR=0x40000000
ADDZEO.,0x7C630595,rD=0x00000000,rA=0x00000000,XER=0x00000000,CR=0x20000000
Can't render this file because it has a wrong number of fields in line 85.

121
cpu/ppc/test/ppctests.cpp Normal file
View File

@ -0,0 +1,121 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
//#include "ppcdisasm.h"
#include "../ppcemu.h"
using namespace std;
int ntested; /* number of tested instructions */
int nfailed; /* number of failed instructions */
/** testing vehicle */
void read_test_data()
{
string line, token;
int i, lineno;
//PPCDisasmContext ctx;
//vector<PPCDisasmContext> tstvec;
uint32_t opcode, dest, src1, src2, check_xer, check_cr;
ifstream tfstream("ppcinttests.csv");
if (!tfstream.is_open()) {
cout << "Could not open tests CSV file. Exiting..." << endl;
return;
}
lineno = 0;
while(getline(tfstream, line)) {
lineno++;
if (line.empty() || !line.rfind("#", 0))
continue; /* skip empty/comment lines */
istringstream lnstream(line);
vector<string> tokens;
while(getline(lnstream, token, ',' )) {
tokens.push_back(token);
}
if (tokens.size() < 6) {
cout << "Too few values in line " << lineno << ". Skipping..." << endl;
continue;
}
opcode = stol(tokens[1], NULL, 16);
dest = 0;
src1 = 0;
src2 = 0;
check_xer = 0;
check_cr = 0;
for (i = 2; i < tokens.size(); i++) {
if (tokens[i].rfind("rD=", 0) == 0) {
dest = stol(tokens[i].substr(3), NULL, 16);
} else if (tokens[i].rfind("rA=", 0) == 0) {
src1 = stol(tokens[i].substr(3), NULL, 16);
} else if (tokens[i].rfind("rB=", 0) == 0) {
src2 = stol(tokens[i].substr(3), NULL, 16);
} else if (tokens[i].rfind("XER=", 0) == 0) {
check_xer = stol(tokens[i].substr(4), NULL, 16);
} else if (tokens[i].rfind("CR=", 0) == 0) {
check_cr = stol(tokens[i].substr(3), NULL, 16);
} else {
cout << "Unknown parameter " << tokens[i] << " in line " << lineno <<
". Exiting..." << endl;
exit(0);
}
}
ppc_state.ppc_gpr[3] = src1;
ppc_state.ppc_gpr[4] = src2;
ppc_state.ppc_spr[SPR::XER] = 0;
ppc_state.ppc_cr = 0;
ppc_cur_instruction = opcode;
ppc_main_opcode();
ntested++;
if ((ppc_state.ppc_gpr[3] != dest) ||
(ppc_state.ppc_spr[SPR::XER] != check_xer) ||
(ppc_state.ppc_cr != check_cr)) {
cout << "Mismatch: instr=" << tokens[0] << ", src1=0x" << hex << src1
<< ", src2=0x" << hex << src2 << endl;
cout << "expected: dest=0x" << hex << dest << ", XER=0x" << hex
<< check_xer << ", CR=0x" << hex << check_cr << endl;
cout << "got: dest=0x" << hex << ppc_state.ppc_gpr[3] << ", XER=0x"
<< hex << ppc_state.ppc_spr[SPR::XER] << ", CR=0x" << hex
<< ppc_state.ppc_cr << endl;
nfailed++;
}
}
}
int main()
{
int i;
cout << "Running DingusPPC emulator tests..." << endl << endl;
cout << "Testing integer instructions:" << endl;
nfailed = 0;
read_test_data();
cout << "... completed." << endl;
cout << "--> Tested instructions: " << dec << ntested << endl;
cout << "--> Failed: " << dec << nfailed << endl;
return 0;
}