Re: [cc65] First steps

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2000-12-31 08:18:32


On Sat, Dec 30, 2000 at 06:00:17PM -0500, troy silvey wrote:
> I am curious if you have a smaller faster program when you
> compile if you use some thing like.....
>
> #define sprite1_x	 *((unsigned char*) 0xD000)
>
> main()
> 	....
> 	sprite_x=0x00
>
> instead of using pointers.

This *is* using pointers. The #define says

"Handle the numeric value 0xD000 as a pointer to an unsigned char, then
dereference this pointer".

> In the end, does the compiler see both the define substitution
> and pointer use equal? Or will one give tigher code than the other?

The #define is substituted in an early stage, so what the compiler will see is
actually

	*((unsigned char*) 0xD000) = 0x00;

Memory access to fixed absolute addresses is one area where the compiler is
quite good, so you don't have to care about the generate code. For long
sequences with several memory accesses, it may be possible to save a byte here
and there with handcoded assembler, but it's usually not worth the effort.
Just have a look at the generated assembler code yourself.

> I was thinking that the structure allocation would use more
> code and space when compiled though.

They get translated into the same assembler code, since the base address of
the structure is a constant, and the field offsets are also constant. So you
may use what you think is most readable.

> I'm thinking  with  more manual manipulation on my
> part, it  might save space and execution time for the code.
> Do you think it could, or am I wasting my time?

There are areas where this is true for cc65, but in the case you've choosen,
you're mostly wasting your time.

Regards


    	Uz


--
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:37 CET