Hello!
First post here so I hope I'm doing things correctly..
I have the Ben Eater 6502 project done... mostly.
I'm using the cc65 tools and have managed to get printing to my LCD working.. sort of.
It handles printing a globally declared char string, but gets super weird printing a locally declared string.
I would expect the ','s to print, followed by the '!'s. Instead I get the ','s then garbage.
Any insight into what I'm doing wrong or misunderstanding about how all of this works would be greatly appreciated.
The following is my c code and then the generated assembly:
Code:
#include "ek6502.h"
unsigned char *command = ",,,,,,,,";
int main() {
unsigned char *c = "!!!!!!!!";
lcdInit();
lcdPrint(command);
lcdPrint(c);
return (0);
}
void handleInterrupt(void) {
}
Code:
;
; File generated by cc65 v 2.18 - Ubuntu 2.18-1
;
.fopt compiler,"cc65 v 2.18 - Ubuntu 2.18-1"
.setcpu "65SC02"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank
.importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
.macpack longbranch
.forceimport __STARTUP__
.import _lcdInit
.import _lcdPrint
.export _handleInterrupt
.export _command
.export _main
.segment "DATA"
_command:
.addr L0001
.segment "RODATA"
L0004:
.byte $21,$21,$21,$21,$21,$21,$21,$21,$00
L0001:
.byte $2C,$2C,$2C,$2C,$2C,$2C,$2C,$2C,$00
; ---------------------------------------------------------------
; void __near__ __fastcall__ handleInterrupt (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _handleInterrupt: near
.segment "CODE"
rts
.endproc
; ---------------------------------------------------------------
; int __near__ main (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _main: near
.segment "CODE"
lda #<(L0004)
ldx #>(L0004)
jsr pushax
jsr _lcdInit
lda _command
ldx _command+1
jsr _lcdPrint
ldy #$01
jsr ldaxysp
jsr _lcdPrint
ldx #$00
lda #$00
jmp L0003
L0003: jsr incsp2
rts
.endproc