|
|
|
|
|
by retrac
1021 days ago
|
|
Your optimizing compiler today will actually optimize. LLVM was recently ported to the 6502 (yes, really) [1]. An example: void outchar (char c) {
c = c | 0x80;
asm volatile ("jsr $fbfd\n" : : "a" (c): "a");
}
void outstr (char* str) {
while (*str != 0)
outchar(*str++);
}
void main () {
outstr("Hello, world!\n");
}
That is compiled to this: lda #$c8 ; ASCII H | 0x80
jsr $fbfd
lda #$e5 ; ASCII e | 0x80
jsr $fbfd
...
Unrolled loop, over a function applied to a constant string at compile time. An assembler programmer couldn't do better. It is the fastest way to output that string so long as you rely on the ROM routine at $fbfd. (Apple II, for the curious.) Such an optimizing transform is unremarkable today. But stuff like that was cutting edge in the 90s.[1] https://llvm-mos.org/wiki/Welcome |
|