-
Notifications
You must be signed in to change notification settings - Fork 18
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 #474 from paulscottrobson/swem
Mods to system for Sweet16 emulation in parallel
- Loading branch information
Showing
12 changed files
with
278 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
cls | ||
mouse show | ||
repeat | ||
b = mouse(x,y,w) | ||
print chr$(20);x,y,w;" " | ||
until false | ||
' | ||
' Sweet 16 test program ; about 6.7 MIPS. | ||
' | ||
mem = alloc(512):reg = alloc(32):stack = alloc(16) | ||
count = 50 | ||
print mem | ||
for pass = 0 to 1 | ||
o = pass*2:p = mem | ||
set 1,count | ||
set 2,0 | ||
set 5,0 | ||
.l1 | ||
add 3 | ||
dcr 2 | ||
bnz l1 | ||
inr 5 | ||
dcr 1 | ||
bnz l1 | ||
rtn | ||
next | ||
|
||
reg[15] = mem:reg[12] = stack | ||
|
||
t1 = time() | ||
sweet reg | ||
elapsed = time()-t1 | ||
print reg[5],reg[15] | ||
if elapsed <> 0 | ||
print elapsed | ||
elapsed = elapsed / 100 / 3 / 65535 / count | ||
ips = 1 / elapsed | ||
mips = ips / 1000000 | ||
print mips | ||
endif |
Binary file not shown.
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
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,104 @@ | ||
// ******************************************************************************************************************************* | ||
// ******************************************************************************************************************************* | ||
// | ||
// Name: 6502.cpp | ||
// Purpose: 6502 Processor Emulation. | ||
// Created: 28th April 2024 | ||
// Author: Paul Robson (paul@robsons.org.uk) | ||
// | ||
// ******************************************************************************************************************************* | ||
// ******************************************************************************************************************************* | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <ctype.h> | ||
#include <cstdint> | ||
#include "sys_processor.h" | ||
#include "sys_debug_system.h" | ||
#include "hardware.h" | ||
#include "common.h" | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// CPU / Memory | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
static BYTE8 a,x,y,s; // 6502 A,X,Y and Stack registers | ||
static BYTE8 carryFlag,interruptDisableFlag,breakFlag, // Values representing status reg | ||
decimalFlag,overflowFlag,sValue,zValue; | ||
static WORD16 pc; | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Generated support functions | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
#include "6502/__6502support.h" | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Reset 6502 | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
void CPUReset6502(void) { | ||
resetProcessor(); // Reset CPU | ||
} | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Execute a single 6502 instruction | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
BYTE8 CPUExecute6502(void) { | ||
BYTE8 opcode = Fetch(); // Fetch opcode. | ||
BYTE8 forceSync = 0; | ||
switch(opcode) { // Execute it. | ||
#include "6502/__6502opcodes.h" | ||
|
||
case 0xF3: // $F3 forces sync in emulator. Not needed in real hardware. | ||
forceSync = 1;break; | ||
} | ||
return forceSync; | ||
} | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Get 6502 PC | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
WORD16 CPUGetPC65(void) { | ||
return pc; | ||
} | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Retrieve a snapshot of the processor | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
static CPUSTATUS65 st; // Status area | ||
|
||
CPUSTATUS65 *CPUGetStatus65(void) { | ||
st.a = a;st.x = x;st.y = y;st.sp = s;st.pc = pc; | ||
st.carry = carryFlag;st.interruptDisable = interruptDisableFlag;st.zero = (zValue == 0); | ||
st.decimal = decimalFlag;st.brk = breakFlag;st.overflow = overflowFlag; | ||
st.sign = (sValue & 0x80) != 0;st.status = constructFlagRegister(); | ||
st.cycles = cycles; | ||
return &st; | ||
} | ||
|
||
// ******************************************************************************************************************************* | ||
// | ||
// Handle skipping subroutine calls | ||
// | ||
// ******************************************************************************************************************************* | ||
|
||
int CPUGetStep65(BYTE8 opcode) { | ||
return (opcode == 0x20) ? 3 : 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
Oops, something went wrong.