Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About constants
#7
LCD Wrote:I just tried to use the inline ASM:
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
I got two warnings:
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?
Are you using the -o2 optimization level? -o2 removed unused variables. Use -o1. See explanation:
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
You can see the 'b' variable is useless: You don't use if for anything. If you use -o2 it will be removed.
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
Which will prevent "source" and "dest" to be removed.

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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)