Code: Select all
__asm__ ("JSR $8A5A")if I put it in a void function, would this work by doing
Code: Select all
void getch()
{
__asm__ ("JSR $8A5A");
}
...
char c;
getch();
__asm__ ("STA %b", c);
Code: Select all
__asm__ ("JSR $8A5A")Code: Select all
void getch()
{
__asm__ ("JSR $8A5A");
}
...
char c;
getch();
__asm__ ("STA %b", c);
Code: Select all
__asm__ ("JSR $8A5A")Code: Select all
void getch()
{
__asm__ ("JSR $8A5A");
}
...
char c;
getch();
__asm__ ("STA %b", c);
Code: Select all
char c;
void getch(void)
{
__asm__("JSR $8A5A");
__asm__("STA %b", c);
}
Code: Select all
.export getch
getch:
; Your code for getch() here.
; Leave the character in the A register before return, that's where the compiler will expect the return value
rts
Code: Select all
int getch(); // Define a prototype, the linker will find this for you now that it's exported from ASM
char c = getch();
Code: Select all
int getch(void)
{
char c;
__asm__ ("JSR $8A5A");
__asm__ ("STA %b", c);
return c;
}
Code: Select all
OBJS=asm1.o asm2.o cfile1.o cfile2.o
# Assemble .s files into .o files
.s.o:
ca65 --cpu 65c02 -I include -o $@ $<
# Compile .c files into .o files
.c.o:
cc65 --cpu 65c02 -I include -o $@ $<
# Generate your program from the above created .o files.
myprogram.bin: $(OBJS)
ld65 $(OBJS) -o myprogram.bin
Code: Select all
int getch(void)
{
char c;
__asm__ ("JSR $8A5A");
__asm__ ("STA %b", c);
return c;
}
Code: Select all
int getch(void)
{
static char c;
__asm__ ("JSR $8A5A");
__asm__ ("STA %v", c);
return c;
}
Code: Select all
; ---------------------------------------------------------------
; int __near__ getch (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _getch: near
.segment "BSS"
L0002:
.res 1,$00
.segment "CODE"
jsr $8A5A
sta L0002
ldx #$00
rts
.endproc
Code: Select all
; ---------------------------------------------------------------
; unsigned char __near__ getch8 (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _getch8: near
.segment "BSS"
L0009:
.res 1,$00
.segment "CODE"
jsr $8A5A
sta L0009
ldx #$00
lda L0009
rts
.endproc
Code: Select all
; ---------------------------------------------------------------
; unsigned char __near__ getch8 (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _getch8: near
.segment "BSS"
L0009:
.res 1,$00
.segment "CODE"
jsr $8A5A
sta L0009
ldx #$00
lda L0009
rts
.endproc