Re: [cc65] CC65 and Stack Pointer

From: Groepaz <groepaz1gmx.net>
Date: 2006-11-29 03:53:04
On Wednesday 29 November 2006 03:43, Hiroji Kimura wrote:
> What locations in the zero page does CC65 use?  Could you tell me which
> document has that information? Also I wonder why our calculator works
> even without saving registers and zero page locations.  We are calling a
> c function within an interrupt and I am pretty sure that it will use
> real 6502 registers. I guess we only have "while(1);" in our main function.

look at the linker script, it defines what zeropage locations to use. (you 
could also have the linker output a mapfile and look there)

> Now, I am just curios. Why does cc65 generate codes which depend on
> subroutines like pushax and the secondary stack?  I understand Small-c
> implementation assumes a primary and a secondary registers.  I guess the
> reason is to make porting the c compiler to different architectures
> easier. Is it one of the reasons?

the main reason for doing that is that the hardware stack of the 6502 is only 
256 byte "large", and also can not be placed anywhere in memory. using the 
hardware stack for everything (like local variables) would limit the compiler 
too much to make it really useable. the hardware stack is only used for 
return adresses (which already limits calling depth to 127 nested calls, not 
counting interrupts which use it aswell) and the software stack is used for 
all the other stuff that a C implementation requires (like local variables).

-- 

http://www.hitmen-console.org
http://www.gc-linux.org/docs/yagcd.html
http://www.pokefinder.org
http://ftp.pokefinder.org

Women don't know what they want; they don't like what they have got. Men know 
very well what they want; having got it, they begin to lose interest. 
<A.W.Adams>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Nov 29 03:53:09 2006

This archive was generated by hypermail 2.1.8 : 2006-11-29 03:53:14 CET