VBCC code generation
Hi
For following code Code:
define CIAADDR (UBYTE*)(0xbfe001) Code:
near code I don't understand why and.l is used, I think that better will be and.b in this case. Is there a way to change this and.l --> and.b and then remove first moveq #0,d0 ? Funny things happen when I'm trying to use __reg for same routine Code:
__reg("d1") UBYTE r = (!(*CIAADDR & (128))); Code:
near code Any comments and explanation are welcome. |
Why did it do AND.L? Because you specifically (though implicitly) asked it to. The default type of an integer is int, which in turn is 32-bits. If you want 128 to represent an unsigned char value, try changing the notation of 128 to 128UC or '\0x80' using single quotes (just typing this from memory, I hope that's right). I know that on SAS/C when you wanted a long constant value instead of a 16-bit int, you had two options: Hit a switch on the compiler that defined all ints as 32 bits instead of 16, or put a capital L after your constant to indicate its type. Another way would be to cast the 128 to UBYTE, which should inline the conversion using constant folding.
*edit* As another suggestion, try #include <stdbool.h> at the beginning of your code so you can return a bool value and cast that to a UBYTE. It might be able to optimize the branches to a SNE D0 and an AND.B #1, D0 eliminating the need for D1 altogether though it might not do this if you're not optimizing for an '060. Like this: Code:
#include <stdbool.h> |
Thanks for answer Samurai Crow. But ... vbcc do not like your suggestion :)
I even tried with (to check if add.b will be generated) Code:
UBYTE c = 128; Code:
near code So it not big deal this and.l but I thought that is possible to optimize a bit generated output. Edit: There is always another way: back to pure asm :) |
Hmm, old thread, but look at the gcc output
-m68000 Code:
_fire: Code:
_fire: |
Quote:
|
Code:
|
Quote:
Quote:
Quote:
Code:
UBYTE asmfire(void)="\tbtst\t#7,$bfe001\n\tsne\td0"; |
Quote:
Side note: Those C compilers sure write good code :rolleyes |
...And from gcc 4.6.4 (atari-mint target)
Code:
_fire: |
Quote:
|
All times are GMT +2. The time now is 10:55. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.