1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 17:30:50 +00:00

11340 Commits

Author SHA1 Message Date
Sergio Lindo Mansilla
17e7e669c9 Fix typo in ca65 doc 2024-12-15 15:29:38 +01:00
Sergio Lindo Mansilla
3933f329c2 Improve description of namespace access in ca65
This avoid confusion with referencing global scope with the namespace
token.
2024-12-15 15:08:32 +01:00
Stefan
0e640877c2
Fixed colour #2540 2024-12-11 14:30:56 +01:00
Colin Leroy-Mira
852b622c43 Apple2: Don't forcefully re-enable IRQ
Avoid enabling IRQ after disabling them in driver code, remember
previous state instead (in case user had them disabled already).
2024-12-09 19:01:00 +01:00
Stefan
0f6b427170
Update strftime.c 2024-12-09 18:37:02 +01:00
Stefan
d993f3a766
Update cc65.sgml 2024-12-09 18:36:05 +01:00
Stefan
cf470dd0df
Update sieve.c 2024-12-09 18:26:00 +01:00
Stefan
5f2c5b58ab
Update overlaydemo.c 2024-12-09 18:25:34 +01:00
Stefan
5d2730f4b4
Update multidemo.c 2024-12-09 00:44:44 +01:00
Stefan
8b008052cb
Update mandelbrot.c 2024-12-09 00:43:35 +01:00
Stefan
26e6717102
Update mandelbrot.c 2024-12-09 00:43:05 +01:00
Stefan
316ee4ad5b
Update overlay-demo.c 2024-12-09 00:42:28 +01:00
Stefan
be6819ca1f
Update plasma.c 2024-12-09 00:41:03 +01:00
Stefan
3612d90c8e
Update fire.c 2024-12-09 00:40:41 +01:00
Sidney Cadot
05b3825683 sim65 : improve implementation of ROL and ROR operations
Issue #2539 brings to light a number of issues in the sim65 simulator.

Several issues can be traced back to undesirable side effects of the
use of bare 'unsigned' types for the CPU registers in the 'CPURegs'
type defined in src/sim65/6502.h.

The intention is to tighten the types of the registers defined there
to uint8_t and uint16_t, in accordance with the actual number of bits
that those registers have in the 6502. However, it turns out that a
handful of opcode implementations depend on the fact that the register
types currently have more bits than the actual 6502 registers themselves
for correct operation. This mostly involves operations that involve
the carry bit (ROL, ROR, ADC, SBC).

In preparation of fixing the CPURegs field types, we will first make
sure that those opcode implementations are changed in such a way that
they still work if the underlying register types are tightened to their
actual bit width.

This PR concerns this specific change for the ROL and ROR operations.

The correct functioning of ROL and ROR after this patch has been verified
by testing against the 65x02 test suite.
2024-12-03 23:33:57 +01:00
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
Bob Andrews
162bc6b305
Merge pull request #2553 from sidneycadot/fix-remove-zregister
Sim65: removed ZR register from CPURegs type.
2024-12-03 02:15:50 +01:00
Sidney Cadot
84c4ea062d Sim65: removed ZR register from CPURegs type. 2024-12-03 01:17:44 +01:00
Bob Andrews
a55d328e78
Merge pull request #2549 from clydeshaffer/debuginfo_doc_port
Port Debug Info page from Wiki to Docs
2024-12-02 00:30:24 +01:00
Bob Andrews
c0a4942b5d
Merge pull request #2550 from sidneycadot/fix-bit-imm
Fixed behavior of the 65C02 "BIT #imm" instruction in sim65.
2024-12-02 00:28:07 +01:00
Bob Andrews
918c39cbeb
Merge pull request #2548 from sidneycadot/fix-branch-timings
Fixed clock-cycle timing of branch (Bxx) instructions.
2024-12-02 00:25:54 +01:00
Bob Andrews
3895caae90
Style fix 2024-12-02 00:25:24 +01:00
Bob Andrews
79e26c1bc5
Merge pull request #2547 from sidneycadot/fix-jmp-ind
Fixed the behavior of JMP (ind) in sim65 when it runs with the 6502X CPU type.
2024-12-02 00:21:31 +01:00
Bob Andrews
1ce8225091
Merge pull request #2551 from sidneycadot/fix-interrupts-dflag
Fixed wrong clearing of D-flag on interrupts for sim65 with 6502X CPU.
2024-12-02 00:19:55 +01:00
Sidney Cadot
e26c17fd50 Fixed wrong clearing of D-flag on interrupts for sim65 with 6502X CPU type.
The 65C02 clears the D flag on interrupts while the 6502 does not.

The old code cleared the D flag also for the 6502X CPU type, which
was incorrect.
2024-12-01 09:59:10 +01:00
Sidney Cadot
1d9d056da5 Fixed behavior of the 65C02 "BIT #imm" instruction.
The BIT #imm instruction behaves differently from the BIT instruction with other
addressing modes, in that it does /not/ set the N and V flags according to the
value of its operand. It only sets the Z flag, in accordance to the value of
(A & operand).

This is corroborated in two ways:

- The 65x02 test suite;
- Documentation about BIT #imm such as http://www.6502.org/tutorials/65c02opcodes.html

This patch implements the correct behavior for BIT with immediate addressing.
The patched version passes the 65x02 test suite for 65C02 opcode 0x89.
2024-11-30 23:46:19 +01:00
Clyde Shaffer
3fdb1a516c small formatting fixes, and a section rename to get it to build 2024-11-30 16:56:25 -05:00
Clyde Shaffer
12f6340878 Add section to ld65 doc about debug info 2024-11-30 16:09:50 -05:00
Sidney Cadot
709d71ef70 Fixed clock-cycle timing of branch (Bxx) instructions.
Branch instructions, when taken, take three or four cycles,
depending on whether a page is crossed by the branch.

The proper check to determine whether the extra cycle must be added
is the target address of the branch vs the address immediately
following the branch.

In the former version of the BRANCH instruction handler, the target
address was incorrectly checked vs the address of the branch instruction
itself.

The corrected behavior was verified against a real 6502 (Atari) and
the 65x02 testsuite.
2024-11-30 19:56:31 +01:00
Sidney Cadot
2abd66ea0c Fixed the behavior of the JMP (ind) instruction in sim65 when it runs with the "6502X" CPU type.
The JMP (ind) bug is present in the 6502 which is emulated by both the "6502" and "6502X"
emulation targets of sim65; specifically, the OPC_6502_6C handler. In the old code, the
bug-exhibiting code was not executed when the target was set to 6502X, which is incorrect.
the patch removes the (CPU == CPU_6502) check, which made no sense.

The JMP (ind) bug was actually fixed in the 65c02. Indeed, the OPC_65C02_6C opcode handler
has code that implements the 'right' behavior.
2024-11-30 12:36:35 +01:00
Bob Andrews
05a653d3f9
Merge pull request #2538 from clydeshaffer/dbg_banknum
[LD65] Add bank number to `seg` entries in dbgfile
2024-11-26 02:27:29 +01:00
Colin Leroy-Mira
21030c22a0 Apple2: Rewrite rewinddir() in assembly 2024-11-17 11:03:58 +01:00
Colin Leroy-Mira
f663ee428d Apple2: Rewrite readdir() and closedir() to assembly 2024-11-17 11:03:58 +01:00
Clyde Shaffer
90e4360958 Parse and report segment bank number in dbginfo module and test shell 2024-11-16 17:13:04 -05:00
Colin Leroy-Mira
700c01fa8b Rename dir_file_count to dir_entry_count 2024-11-15 19:25:40 +01:00
Colin Leroy-Mira
40d9f3eed5 Apple2: Provide a way to get directory file count
The information is available in the directory key block.
Providing it to the user as soon as opendir() is done
can save them costly code.
2024-11-15 19:25:40 +01:00
Clyde Shaffer
fa80e171a2 [LD65] Add bank number to dbgfile 2024-11-12 01:57:27 -05:00
Bob Andrews
36132a437b
Merge pull request #2478 from alexthissen/lynx-include
Lynx cc65 and ca65 include file improvements for Mikey and Suzy
2024-11-09 20:10:51 +01:00
Alex Thissen
a945bedefc Replaced all C++ style comments from Lynx include files 2024-11-09 19:46:11 +01:00
Bob Andrews
e07cdd0a80
Merge pull request #2533 from colinleroy/apple2-rewrite-opendir-asm
Apple2: Rewrite opendir in assembly
2024-11-09 19:35:48 +01:00
Colin Leroy-Mira
819a314508 Apple2: Rewrite opendir in assembly
58 bytes size gain
2024-11-09 18:17:30 +01:00
Alex Thissen
4036912463 Fix to trailing whitespace 2024-11-09 12:06:37 +01:00
Alex Thissen
3dad6c76fa Changed to C style comments 2024-11-09 12:01:22 +01:00
Alex Thissen
0c018919fe Removed union and structures for Suzy math 2024-11-09 11:45:41 +01:00
Alex Thissen
1f1a004a05 Minor tweaks to Suzy struct types.
Named math union
2024-11-09 11:45:41 +01:00
Alex Thissen
489989f4c8 Changed 0x hex values to % binary values 2024-11-09 11:45:41 +01:00
Alex Thissen
336c4287c5 Missed some dangles spaces 2024-11-09 11:45:41 +01:00
Alex Thissen
abcb073a5a Bit definitions for Suzy 2024-11-09 11:45:41 +01:00
Alex Thissen
7150fdf4b9 Enumerations and math structures for Suzy 2024-11-09 11:45:41 +01:00
Alex Thissen
3553975b02 Math improvements to Suzy include file 2024-11-09 11:45:41 +01:00