03-10-2009, 08:41 PM
LCD Wrote:I just tried to use the inline ASM:Are you using the -o2 optimization level? -o2 removed unused variables. Use -o1. See explanation:
I got two warnings:Code:dim source as uinteger
dim dest as uinteger
dim a as ubyte
for a=0 to 191
source=a*32
dest=16384+a*32
asm
ld hl,(_source)
ld de,(_dest)
ld bc,32
ldir
end asm
next a
dest and source are never used (?) and undefined label "_source" (surely also undefined label "_dest") was critized.
The fact is, these variables are used. I wonder also why the _source and _dest are undefined labels, even if I try to use source=0 and dest=0 in the source. I checked the asm output, but only _a was defined with defb. Btw: PRINT was not used, but it was included in the asm source.
I'm using the version 1.1.0 by the way.
Maybe you know the reason?
The problem here is that the compiler does not know anything about the assembler level. So 'ld hl,(_source)' is taken as is. It is not intelligent enough to understand you're accesing a variable from the assembler layer directly.
For example, if you create a program like this:
Code:
a = 1
b = 1
print a
In your listing you're having the same problem because the compiler does not know anything about the asm level. This problem also exists in other compilers and it's usually fixed with a directive.
You can avoid this by using -o1 compiler option, or just do something like:
Code:
REM this code will be optimized and removed
dummy = source
dummy = dest
I'm also studying the PRINT library inclusion (this is due to a reorder of the attributes routines for higher speed). Will fix it in 1.1.1.