Qbasicnews.com

Full Version: UDTs and arrays cause invalid instruction operands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The following code generates invalid ASM code when using FreeBASIC Compiler - Version 0.05b

Code:
Type MyType
      
         A as byte
         B as integer
         c as short
         d as long
         e as single
         f as double
      
      end type
      
      dim X as MyType
      dim Y(0 to 7) as integer
      
      print x.a
      print x.b
      print x.c
      print x.d
      print x.e
      print x.f
      
      for x.a = 0 to 7
         print y(x.a)
      next x.a

The following errors are reported by the compiler:

Quote:E:\freeBASIC>fbc -v -r examples\vartest.bas
FreeBASIC Compiler - Version 0.05b
Copyright © 2004-2005 Andre Victor T. Vicentini (av1ctor@yahoo.com.br)

compiling: examples\vartest.bas -o examples\vartest.asm
assembling: --strip-local-absolute examples\vartest.asm -o examples\vartest.o

examples\vartest.asm: Assembler messages:
examples\vartest.asm:83: Error: suffix or operands invalid for `movsx'
examples\vartest.asm:84: Warning: using `%esi' instead of `%si' due to `l' suffix
examples\vartest.asm:93: Error: suffix or operands invalid for `movsx'
examples\vartest.asm:94: Warning: using `%esi' instead of `%si' due to `l' suffix

Also, I noticed that it forced dword alignment on each element of the UDT. Can you either a) not do that by default or b) have a NoAlign option (per UDT)? ie:

Code:
Type MyType NoAlign

         A as byte
         B as integer
         c as short
         d as long
         e as single
         f as double
      
      end type

For most things, this is not needed, but for communication buffers, it's is critical.
looks like i am usefulk for someth8ng (bringing FB to eric's attn)
...and nobody cares...

Quote:all UDT elements are aligned and the UDT size is rounded to multiple of len( integer ) - all 32-bit C compilers do the same by default.

To turn that off, use:

Type BITMAPHEADER Field=1
...
End Type

No alignament or padding will be done then.
"Typed variable not allowed in expression", that's what QB will barf if you don't use simple scalars with FOR counters.. i guess i will have to add that too.