1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 22:30:12 +00:00
cc65 - a freeware C compiler for 6502 based systems
Go to file
Sidney Cadot fbd8961be1 sim65: changing memory access types to uint8_t and uint16_t.
In sim65, simulator memory access to a 64 KB array is implemented via functions
defined in src/sim65/memory.h and src/sim65/memory.c.

In the old version, the types for both content bytes (8 bits), content words
(16 bits), regular addresses (16 bits), and zero-page addresses (8 bits) were
all given as bare 'unsigned'.

This lead to several cases of address overrun (e.g., when an instruction wraps
around from address 0xffff to 0x0000) when running the simulator against a
stress test (specifically, the 65x02 test suite). To protect from this, and to
more properly express the bit width of the types involved which is a good idea
anyway, we start using the fixed-width types provided by 'stdint.h'.

In the process, we also change the MemReadByte macro to a full function call.
This may impact performance (by a small amount), but it improves memory safety,
as cases where the address is accidentally expressed as a value exceeding 0xffff
are handled by wrap-around (as it is in the actual hardware), rather than causing
access outside of the Mem[] array where the 64 KB of simulated RAM resides.

The reason for this patch is twofold.

(1) It is a partial patch for issue #2539.

Several issues brought to the surface by running the 65x02 testsuite are
eliminated by these changes. In the discussion about this issue, it was
concluded that it is a Good Idea to use the stdint-types, both for the
simulated CPU registers and for the memory. This patch addresses the
memory-part of that change.

(2) It is a precursor patch for issue #2355.

For that issue, we will implement a memory-mapped timer register. This will
make handling of memory access in the simulator a bit more complex.

Having proper functions with the proper types in place will help to make the
timer register patch easier.
2024-12-03 21:21:49 +01:00
.github Make lastline.sh ignore empty files. Fixes #2514. 2024-09-12 09:10:37 +02:00
asminc Changed 0x hex values to % binary values 2024-11-09 11:45:41 +01:00
cfg Added asm configs for C16 & Plus/4 2024-06-16 19:14:24 +03:00
doc Merge pull request #2549 from clydeshaffer/debuginfo_doc_port 2024-12-02 00:30:24 +01:00
include Rename dir_file_count to dir_entry_count 2024-11-15 19:25:40 +01:00
libsrc Apple2: Rewrite rewinddir() in assembly 2024-11-17 11:03:58 +01:00
samples Update checkversion.c 2024-10-21 10:09:00 -05:00
src sim65: changing memory access types to uint8_t and uint16_t. 2024-12-03 21:21:49 +01:00
targettest Overlooked a few target tests that take the address of main(). 2024-09-02 16:55:58 +02:00
test Merge pull request #2522 from kugelfuhr/kugelfuhr/code-optimizations 2024-10-05 15:03:46 +02:00
util Merge pull request #1871 from clbr/da816 2022-12-30 15:34:40 +01:00
.editorconfig Fixed EOL settings (LF vs CRLF) for Visual Studio. 2023-10-11 23:57:45 +08:00
.gitattributes Added .gitattributes to force LF line endings on commit. 2017-03-12 18:13:18 +01:00
.gitignore Revert the change to .gitignore so git status doesn't report a clean status as 2024-09-13 19:02:13 +02:00
.travis.yml Don 2021-09-29 14:48:09 +02:00
Contributing.md add comment on function prototypes 2024-09-08 17:08:40 +02:00
LICENSE Simplified license. 2015-05-05 21:56:23 +02:00
Makefile libtest target alternative to libs 2023-05-05 21:56:52 -04:00
Makefile.travis The doc now lives in the 'master' branch of the 'doc' project. 2018-09-18 23:39:11 +02:00
README.md Some clarification 2024-08-10 15:29:50 +02:00

The cc65 cross-compiler suite

cc65 is a complete cross-development package for 65(C)02 systems, including a powerful macro assembler, a C compiler, linker, archiver, simulator and several other tools. cc65 has C and runtime library support for many of the old 6502 machines. For details look at the cc65 web site:

Company / People Machine / Environment
Apple Apple II
Apple IIe enhanced
Atari Atari 400/800
Atari 2600
Atari 5200
Atari 7800
Atari XL
Lynx
Tangerine Oric Atmos
Eureka Oric Telestrat
Acorn BBC series
Commodore C128
C16
C64
CBM 510/610
PET
Plus/4
VIC-20
VTech CreatiVision
Commander X16 Community Commander X16
Bit Corporation Gamate
Berkeley Softworks GEOS (Apple/CBM)
LUnix Team LUnix (C64)
Nintendo Nintendo Entertainment System (NES)
Ohio Scientific OSI C1P
MOS Technology, Inc. KIM-1
NEC PC Engine (PCE)
Dr. Jozo Dujmović Picocomputer (RP6502)
Watara Watura/QuickShot Supervision
Synertek SYM-1

A generic configuration to adapt cc65 to new targets is also around.

People

cc65 is originally based on the "Small C" compiler by Ron Cain and enhanced by James E. Hendrix.

Project founders

  • John R. Dunning: original implementation of the C compiler and runtime library, Atari hosted.
  • Ullrich von Bassewitz:
    • moved Dunning's code to modern systems,
    • rewrote most parts of the compiler,
    • rewrote all of the runtime library.

Core team members

External contributors

(The above list is incomplete, if you feel left out - please speak up or add yourself in a PR)

For a complete list look at the full team list or the list of all contributors.

Contact

For general discussion, questions, etc subscribe to the mailing list or use the github discussions.

Some of us may also be around on IRC #cc65 on libera.chat.

Documentation

  • The main Documentation for users and developers.
  • Info on Contributing to the CC65 project. Please read this before working on something you want to contribute, and before reporting bugs.
  • The Wiki contains some extra info that does not fit into the regular documentation.

Downloads

Snapshot Build