1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-17 16:29:32 +00:00
Commit Graph

121 Commits

Author SHA1 Message Date
Bob Andrews
a372ead4de
Merge pull request #2334 from carlo-bramini/fix-sim65-1
[SIM65] Support undocumented opcodes for 6502
2024-03-10 00:37:18 +01:00
Carlo Bramini
b04d79b1da [SIM65] Support undocumented opcodes for 6502
This PR is mostly a complete rewrite of the emulator for 6502/65c02 opcodes.
It provides an easier to maintain implementation of the instructions, by using few macros rather than having hand-written code for each function.
All undocumented, previously missing opcodes for 6502 are also implemented.
The patch also includes a detailed documentation of those opcodes, for reference to developers.
This PR should fix one of the milestones listed here for the next version of CC65:

https://github.com/cc65/wiki/wiki/Before-the-next-release
2024-02-08 12:13:17 +01:00
Colin Leroy-Mira
0dd7b0c3a5 Implement __sysremove for sim65
This will allow using unlink()/remove() in sim65 programs
Use it to unlink fgets' test output file
2024-01-28 13:58:57 +01:00
bbbradsmith
f15e9c4159 Linux build rejects %llu in ErrorCode 2023-05-07 17:41:54 -04:00
bbbradsmith
2cb457b85f sim65 use error codes outside the simulated program's range for non-sim errors 2023-05-07 16:51:12 -04:00
bbbradsmith
0081fe548c sim64 universal 64-bit cycle count support:
MaxCycleCount is accounted by countdown, eliminating the 1-instruction-overhead issue, and removing the need to compare against a growing TotalCycles.
Makes main.c responsible for counting total cycles, instead of 6502.c, so the size of MaxCycleCount etc. is fully determined in one location.
Makes error.c responsible for PrintCycles instead of paravirt.c, so that it can be treated globally instead of
Return value of main() should be SIM65_ERROR because it is unreachable by design.
2023-05-07 16:26:42 -04:00
bbbradsmith
84f0ab322d sim65: cycles does not increment 1 at a time, so some small overhead is needed in range check 2023-05-06 13:54:28 -04:00
bbbradsmith
c03d00bc80 sim65 suppress uninitialized variable warning
the EOF check was protecting uninitialized Val2 but the compiler can't figure that out
2023-05-05 21:46:42 -04:00
bbbradsmith
773716c32a sim65 close(-1) crash fix
test/val/constexpr.c relies on close(-1) to return -1 for some reason (comment says "abuse"), but on MSVC close(-1) is treated as a security issue and terminates the program instead of returning -1
simulating this desire for sim65, though constexpr.c may also warrant a review
2023-05-05 21:46:11 -04:00
bbbradsmith
f2e7609046 sim65 cycles 32-bit range fix
long is 64-bit on some platforms, making this inconsistent, added range check to catch overflow.
reduced tests requesting 5 billion cycles to 2^32-1 so they can fun on 32-bit long sim65.
2023-05-05 21:45:57 -04:00
bbbradsmith
4d30333099 sim65 path length safety for PVOpen 2023-02-19 05:31:46 -05:00
Lauri Kasanen
b052e64089 Speed up sim65 by 10% 2022-10-17 13:32:38 +03:00
mrdudz
3c1bb85b8e remove dangling spaces 2022-04-17 16:07:09 +02:00
Matthew D. Steele
22a3d55e40 Add space after function names 2022-01-08 16:39:30 -05:00
Matthew D. Steele
1f6bc6240f Move local variable declaration to top of block 2022-01-08 16:29:42 -05:00
Matthew D. Steele
92bfbeb8ab Adjust Pop() sequencing in paravirt.c 2022-01-08 16:24:40 -05:00
Matthew D. Steele
cf1bc4fad4 Fix Pop() implementation in src/sim65/paravirt.c (fixes #1625)
The Pop() function was not handling stack pointer wrap around correctly.

Also, change the simulated RTS implementation in ParaVirtHooks() to
explicitly sequence the two Pop() calls in the correct order.
2022-01-07 09:56:46 -05:00
Oliver Schmidt
5d84a4ba13 Removed non-ASCII chars. 2021-04-19 16:06:10 +02:00
Greg King
fb0d09a277 Changed sim65's internal error codes from 9-bit values to 7-bit values.
Some shells truncate process return codes to 8 bits.  And, the eigth bit often is used to show that a signal stopped the process.
2019-12-06 14:47:47 -05:00
bbbradsmith
5269552346 sim65 common define for paravirt hooks base location
allows the loaded binary to take up as much space as possible
restored some documentation of the hooks but without reference to specific location
2019-05-31 10:40:04 +02:00
Oliver Schmidt
6efb71bea7 Rearranged paravirt function vector.
- exit right below 6502 vectors.
- keep exit addr stable as it may be called from asm.
2019-05-30 00:10:17 +02:00
bbbradsmith
7e4c4ee53e sim65/main.c spaces were requested 2019-05-29 22:56:51 +02:00
bbbradsmith
fb7d4acd5c versionable header for sim65
load and run address now configured from header
fix error codes not to conflict with test
fix test/misc/endless.c which is supposed to fail if an endless loop does not occur
2019-05-29 22:56:51 +02:00
bbbradsmith
07ca772932 adjust literal width to match variable type 2019-05-29 22:56:51 +02:00
bbbradsmith
2f3cae0d2e movable sp for sim65 2019-05-29 22:56:51 +02:00
Stefan
08ec9fc392 Fixed 65C02 timing again. 2019-02-12 11:15:47 -05:00
Stefan
50fd96bbab
Fixed 65C02 timing. 2019-02-07 12:19:49 +01:00
Greg King
a6b04f6e97 Changed most "backticks" (grave accents) into apostrophes.
Quotations that are embraced by tick marks now look better, in most fonts.
2019-01-05 14:57:12 -05:00
Oliver Schmidt
3598fb505d Fixed Visual C++ build (and some style adjustments). 2018-08-19 00:01:40 +02:00
Patrick Pelletier
e549e23a87 Use non-POSIX values for S_IREAD and S_IWRITE.
(As requested in the PR.)
2018-08-17 23:28:45 +02:00
Patrick Pelletier
f72d355b18 sim65: Use mode_t for OMode. 2018-08-17 23:28:45 +02:00
Patrick Pelletier
b30f790587 sim65: Blindly guessing to get Travis build to pass. 2018-08-17 23:28:45 +02:00
Patrick Pelletier
a7d158e077 sim65: Build was failing on Windows, too.
Microsoft loves putting underscores in front of everything!
2018-08-17 23:28:45 +02:00
Patrick Pelletier
12fbdbf418 sim65: S_IREAD and S_IWRITE are nonstandard.
The Linux build was failing with:

sim65/paravirt.c: In function ‘PVOpen’:
sim65/paravirt.c:217:18: error: ‘S_IREAD’ undeclared (first use in this function)
         OMode |= S_IREAD;
                  ^
sim65/paravirt.c:217:18: note: each undeclared identifier is reported only once for each function it appears in
sim65/paravirt.c:220:18: error: ‘S_IWRITE’ undeclared (first use in this function)
         OMode |= S_IWRITE;
                  ^
make[1]: *** [../wrk/sim65/paravirt.o] Error 1
2018-08-17 23:28:45 +02:00
Patrick Pelletier
974188796c sim65: If mode argument is omitted, use a reasonable default. 2018-08-17 23:28:45 +02:00
Patrick Pelletier
aba320eade Allow "mode" argument to open() to be passed from 6502 code.
Implements this suggestion:
https://github.com/cc65/cc65/pull/719#issuecomment-413809096
2018-08-17 23:28:45 +02:00
Patrick Pelletier
d602572bbe Fix permissions for files created by sim65.
Files created by my programs running under sim65 had really weird permissions:
--w-r--r-x  1 ppelleti  staff  19 Aug 16 23:22 json.test.print.tmp

So, for example, my program running under sim65 was not able to read
the file it had just written.

This is because the third argument to open (mode) was not being
specified in paravirt.c, so it was just picking up random crud off the
stack to use as the mode.

I added a mode of 0666, and now my program runs correctly.
2018-08-17 23:28:45 +02:00
Patrick Pelletier
5cdaa96e4c sim65: Fix "$2C: BIT abs" to access the correct address.
Bug is documented here:
http://forum.6502.org/viewtopic.php?f=2&t=5242
2018-08-10 12:58:48 -07:00
prandeamus
1a95be9c3a 65C02 JMP (ind,x) opcode 7C 2018-01-14 19:42:29 +00:00
prandeamus
009f56afb6 65C02 version too. 2018-01-13 22:42:39 +00:00
prandeamus
c23f264fe4 Call ParaVirtHooks on JMP (indirect) 2018-01-13 18:30:53 +00:00
Greg King
dce5783dc9 Fixed the simulations of the stack pointer and the "break" and decimal-mode flags.
* The pointer wraps around the stack page.
* The break flag exists on only the stack, and only after an interrupt.
* 65C02 interrupts clear the decimal-mode flag.
2017-04-04 13:23:44 -04:00
Oliver Schmidt
cbb2833c01 Merge pull request #414 from IrgendwerA8/SED_Fix
Fixed sim65 SED
2017-03-30 12:26:37 +02:00
IrgendwerA8
170d96898f Fixed SED 2017-03-30 12:17:29 +02:00
IrgendwerA8
cc82cd9992 Fixed addressing error for TSB/TSR and enabled tests again. 2017-03-20 21:53:07 +01:00
IrgendwerA8
e14e13abf4 fixed curly brackets for single line scopes 2017-03-18 22:52:13 +01:00
IrgendwerA8
ad003e5991 style changes 2017-03-18 20:27:41 +01:00
IrgendwerA8
0985655ac7 Fixed bug in original sim65 implementation (reason for C&P error in last commit) 2017-03-18 17:02:22 +01:00
IrgendwerA8
c50e4d25e2 additional fix for scrambled code (sorry) 2017-03-18 16:56:36 +01:00
IrgendwerA8
4ba34f2a69 fixed scrambled semicolon 2017-03-18 16:54:00 +01:00