6

I stumbled upon a divergence in the ASCII upper case/lower case handling when using assembler and linker of the cc65 suite separately (I used cc65 V2.15 on Win10).

For a test I made the following assembler file helloworld.s for the default target (C64):

           ;code for a BASIC line containing SYS2061
           .byte $0B,$08,$e3,$07,$9e,$32,$30,$36,$31,$00,$00,$00

           lda #<textout
           ldy #>textout
           jmp $AB1E

textout:   .asciiz "hello world"

When I assemble and link the file with the command cl65 -C c64-asm.cfg helloworld.s -o helloworld.prg I get a program that outputs "hello world" on the C64 - it appears with uppercase letters with the default charset.

However, when I assemble to an object file first with ca65 helloworld.s and then link the object file with cl65 -C c64-asm.cfg helloworld.o -o helloworld.prg, I get a program that outputs the respective PETSCII characters when viewed with the default charset or, in lower case mode, "HELLO WORLD".

So why is there a difference between the two ways of building? Both cl65 and ca65 are from the cc65 toolchain. Second, is there a way to annotate the source code or to instruct ca65 not to change the case of the ASCII text?

  • Thanks to Raffzahn's great answer, I can confirm that assembling with a specified target ca65 -t c64 helloworld.s enables the proper (C64-oriented) handling of characters. – Peter B. Oct 18 '19 at 17:19
  • BTW your release is four years old, you should update. – Polluks Oct 23 '19 at 0:09
7

Simple reason

CL65 is using "C64" target, while CA65 uses "none".

Adding a -t none should make this disappear.


Details:

The CL65 documentation for -t does clearly point out the difference:

-t sys, --target sys

The default for this option is different from the compiler and linker in the case that the option is missing: While the other tools (compiler, assembler and linker) will use the "none" system settings by default, cl65 will use the C64 as a target system by default. This was chosen since most people seem to use cc65 to develop for the C64.

It's always good to keep in mind that CL65 is 'just' a 'wraper' to combine the various tools (in this case CA65 and LD65) to ease use. It should simplify handling by reducing what to type. Like any tool, meant to simplify things, it either cuts off abilities and/or replaces them by assumptions.


Background:

LD65 automatic translates all (recognized) strings into the appropriate code set, depending on the target, when linking. Since CC65 and it's tools are meant to support various systems, each with it's own charset, the handling of text is postponed until linking. A very nice decision to allow not only machine independent source code but object modules as well. So the on module can be compiled and linked for an Apple II as well as for a PET without the need for recompilation.

For the C64 codeset used is (C64-)PETSCII and only uppercase chars, as this guarantees working independent of the selected version.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.