Search found 2 matches

by milap
Tue Sep 04, 2018 3:35 am
Forum: Newbies
Topic: How to pass arguments to the 6502 code from C?
Replies: 3
Views: 2539

Re: How to pass arguments to the 6502 code from C?

Welcome!

It looks like the answers can be found in the cc65 wiki:
Parameter passing and calling conventions
which has an example, and explains that the callee must clean up the parameter stack.

You need to use the zeropage pointer 'sp', as explained:
The runtime zeropage locations used by the ...
by milap
Mon Sep 03, 2018 11:53 pm
Forum: Newbies
Topic: How to pass arguments to the 6502 code from C?
Replies: 3
Views: 2539

How to pass arguments to the 6502 code from C?

I am trying to compile C and 6502 code using cc65 simulator. I wish to pass value as an argument to the 6502 code? How do I do that?

My C code "main.c":

#include<stdio.h>
#define N 10

int foo(int data);
int main() {
uint8_t p = foo(N);
printf("%u\n",p);
return 0;
}


My 6502 code "foo.s ...