[cc65] lines of code, memory, etc

From: Tachdaun <tachdaun1gmail.com>
Date: 2008-11-28 21:38:15
Ullrich von Bassewitz wrote:
> Good evening!
>
> You can use -I path/to/includes on the command line to add an additional
> search path for includes.
>
> Regards
>
>
>         Uz

Thanks!
I'm using a script to compile, assemble and link, so I just changed the 
current directory to that of the source file being compiled and worked fine.
All this years using Visual Studio made me lose my abilities with 
command line compilers :D

---
A question of choice: what would be better, taking into account code 
size, execution time and memoy consumption( declaring additional 
variables ) ?

// addr( x )  means:    (*(unsigned char*) ( x ))      it's the value of 
the given address

code 1:
    joy_state |= ( addr(joypad) & 1 );            // Push A            
    button state bit to joy_state's bit 0
    joy_state |= ( addr(joypad) & 1 ) << 1;    // Push B                
button state bit to joy_state's bit 1
    joy_state |= ( addr(joypad) & 1 ) << 2;    // Push Select    button 
state bit to joy_state's bit 2
    joy_state |= ( addr(joypad) & 1 ) << 3;    // Push Start        
button state bit to joy_state's bit 3
    joy_state |= ( addr(joypad) & 1 ) << 4;    // Push Up            
button state bit to joy_state's bit 4
    joy_state |= ( addr(joypad) & 1 ) << 5;    // Push Down        
button state bit to joy_state's bit 5
    joy_state |= ( addr(joypad) & 1 ) << 6;    // Push Left        
button state bit to joy_state's bit 6
    joy_state |= ( addr(joypad) & 1 ) << 7;    // Push Right        
button state bit to joy_state's bit 7

or code 2:
    unsigned char iter;
    for( iter = 0; iter <= 7; ++iter )
        joy_state |= ( addr(joypad) & 1 ) << iter;

of course, code 2 declares one variable that code 1 doesn't, and it has 
the overhead of checking the loop conditions.
But code 2 has fewer lines of code than code 1. I know that in asm it's 
more than 2 lines, but I guess it's fewer than code 1
Which would you choose?

Thanks in advance!


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Dec 28 20:38:47 2008

This archive was generated by hypermail 2.1.8 : 2008-12-28 20:38:49 CET