C Programming in 6502 – CC65 Compiler Does Not Support Float Type


The compiler from (www.cc65.org) supports compilation for 8bit NES files. The 8bit NES are ROM for 8 bit Nintendo Entertainment System FC (Family Console) and the hardware is very limited: 8bit 6502 CPU which has a frequency 1.78MHz, The RAM available is only 2K and the resolution is 256×240.

The CC65 compiler is not only for NES files, it can be used to generate other executables for other platforms as well. Therefore, even through the following works OK.

1
2
3
4
5
6
7
#include "conio.h"
 
void main() {
    cprintf("%d\n", sizeof(float));
    cprintf("%d\n", 355/113);
    for(;;);
}
#include "conio.h"

void main() {
	cprintf("%d\n", sizeof(float));
	cprintf("%d\n", 355/113);
	for(;;);
}

It says the size for float type is 4. But when you declare a variable like this:

1
float x = 1;
float x = 1;

It will complain that Fatal: Floating point type is currently unsupported. That indicates that floating type is not supported by 6502 CPU. In modern PC, there will be usually FPU (floating point unit) that handles the floating point computation, without that, all floating point computation will have to be emulated by CPU, and that is time consuming.

The conclusion is float (single) type is not supported in CC65 for NES and let alone double type.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
255 words
Last Post: Coding Exercise - Timus Online Judge - C++ solution - 1197. Lonesome Knight
Next Post: Tutorial - 7 - C Programming in 6502 - Colour Setting for NES

The Permanent URL is: C Programming in 6502 – CC65 Compiler Does Not Support Float Type

Leave a Reply