Skip to main content
18 votes
Accepted

cprintf printing invisible characters in C program on VIC 20

The Fix for cc65 This was discussed in cc65 issue #946 and fixed by cc65 PR #965. That was merged to the master branch on 2019-10-26, and should appear in V2.19 of cc65. (I don't know when that ...
cjs's user avatar
  • 28k
14 votes
Accepted

Labels in cc65 inline assembler with #define macro

Since the inline assembler of cc65 doesn't accept anonymous labels (from my other answer), another approach is to provide a unique suffix to the labels, which can be applied by the macro. The ...
Chromatix's user avatar
  • 16.9k
12 votes
Accepted

Different handling of ASCII interpretation between ca65 and cl65

Simple reason CL65 is using "C64" target as default, while CA65 uses "none". Adding a -t none should make this disappear. Details: The CL65 documentation for -t does clearly point ...
Raffzahn's user avatar
  • 236k
11 votes
Accepted

Macro for counted string accepting multiple arguments?

TL;DR: This macro will solve your issues: .feature string_escapes .macro PString Arg .byte :++ - :+ : .byte Arg : .endmacro When called with more than one argument the ...
Raffzahn's user avatar
  • 236k
8 votes
Accepted

Adding control characters to string constants in ca65 assembler

Is there an escape character in ca65 to add such commands to a text string? In general: No. The whole ASCII(Z) mechanic is meant to write device independent code, so adding device specific sequences ...
Raffzahn's user avatar
  • 236k
8 votes
Accepted

Printing German umlauts with cc65

Your source is most likely in ISO 8859-1 (or -15) encoded (*1), so the compiler has to do code conversion between character literals in your source and the designated target. Without a specifying a ...
Raffzahn's user avatar
  • 236k
6 votes
Accepted

How to pass a value to an inline assembler script in a #define macro in cc65

There is a pseudo variable __AX__ of type unsigned int that can be assigned a value that then ends up in register A (lo byte) and X (hi byte). So, the following macro definition works as intended: #...
Peter B.'s user avatar
  • 4,531
6 votes

Efficiently defining a C function by given address in cc65

Preface: I'm not the world greatest C expert - not at least as I dislike C quite a lot :)) What Happenes The general issue here is that CC65 puts the address into a pointer variable, visible when ...
Raffzahn's user avatar
  • 236k
5 votes
Accepted

Putting code into two different memory areas with cc65/ca65

(Caveat: This is from memory with a quick peek into the manual. So some reply after trying it might be useful.) TL;DR; Fill it Try fill=yes (*1) for the memory area of MAIN and make HIMEMSEG overwrite ...
Raffzahn's user avatar
  • 236k
5 votes
Accepted

CC65 ignores request to correctly offset memory areas in output files

[I'm not sure what the issue is, as the wording isn't very clear, so I might entirely misinterprete this.] Given that I said the memory areas begin at $4000 and $8000, I was expecting to see the ...
Raffzahn's user avatar
  • 236k
4 votes

How to assign code to different PRG-ROM banks on an NES ROM using ca65/ld65

How do I set up multiple banks on an NES ROM using ca65/ld65? Do you have a clear description how that ROM structured? Or, nowadays it's more like, how the 'ROM' file structure for that system (and ...
Raffzahn's user avatar
  • 236k
4 votes
Accepted

Is there a way to have the ca65 assembler only expand macros?

It appears the answer is no: ca65 is a single-pass assembler and unlike C and NASM, there is not a stand-alone preprocessing stage in the assembly process. Moreover, the design of some of the ...
user3840170's user avatar
  • 25.2k
4 votes

Labels in cc65 inline assembler with #define macro

You can use anonymous labels in ca65. The equivalent to your example code using these, but without the C wrapping, would be: CMP #$60 BCC :+ AND #$DF BNE :++ : AND #$3F : You can also use :- ...
Chromatix's user avatar
  • 16.9k
3 votes
Accepted

How to read disk files using CBM specific functions in cc65 with proper error checking

Adding this to the code as per @tofro's suggestion: unsigned char kernel_getin(void *ptr, unsigned char *size) { unsigned char * data = (unsigned char *)ptr; unsigned char i; unsigned ...
Stavr00's user avatar
  • 938
3 votes
Accepted

How do I save data from a program with CC65

Here is an example of using (mostly) the C library functions to write and read data to/from a file. The _filetype is an addition to select the file type. For data storage on the CBM machines, ...
Peter B.'s user avatar
  • 4,531
2 votes

How do I save data from a program with CC65

The previous answer is probably sufficient. But in case you need more examples, in DestinyHunter I wrote a level-editor that compiled with cc65. The specific source is in: https://github.com/...
voidstar's user avatar
  • 129
2 votes

Printing German umlauts with cc65

I would expect that the CC65 compiler, like most compilers, would output string literals using whatever sequence of bytes appears in the source file. If you want to ensure that particular byte values ...
supercat's user avatar
  • 39.2k
2 votes
Accepted

ca65 vs tass syntax: converting a hex address to decimal?

ca65 was designed as a single-pass assembler. So this works: addr = 4096 .byte $9e,.sprintf("%d", addr) but this does not: .byte $9e,.sprintf("%d", addr) addr = ...
fadden's user avatar
  • 9,368
2 votes
Accepted

Is there a way to use .ident or * (PC) in numeric macro variables (using .set)?

Like the name says, they are numeric variables. They can hold numbers and nothing else. This is confirmed by the documentation. I would instead try something like this: __word_last .set 0 __word_0 = 0 ...
user3840170's user avatar
  • 25.2k
1 vote

Macro for counted string accepting multiple arguments?

ca65 doesn't seem particularly retro to me but you could do it recursively: .macro StringHelper p0, p1, p2, p3, p4 .ifnblank p0 .byte p0 StringHelper p1, p2, p3, p4 .endif ....
Kelvin Sherlock's user avatar
1 vote
Accepted

Efficiently defining a C function by given address in cc65

Thanks for the discussions and suggestions. I summarize here the multiple ways to define a function with a given address as a C function. Assigning a function pointer The call described in the ...
Peter B.'s user avatar
  • 4,531
1 vote

Efficiently defining a C function by given address in cc65

While I've not actually used CC65, I'm familiar with the 6502, and I would expect that if you do something like: unsigned char springboard[5]; // At file scope ... ... within a function ((void(*)(...
supercat's user avatar
  • 39.2k
1 vote

Putting code into two different memory areas with cc65/ca65

The solution is to declare the MAIN memory region's size so it ends at the start of the HIMEM memory region and then add fill=yes to MAIN so it get's filled. This will have the same result as using * ...
BlackJack's user avatar
  • 319

Only top scored, non community-wiki answers of a minimum length are eligible