Clearing Structures

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
Darrel Taylor
Posts: 29
Joined: Wed Oct 04, 2006 4:44 pm
Location: California

Clearing Structures

Post by Darrel Taylor » Sat Oct 21, 2006 11:44 pm

Hi David,

Here's an odd little problem I came across.

If a structure contains 3 or less (single byte) variables. It only clears the first byte of the structure. For instance...

Code: Select all

Structure Astruct
  A As Byte
  B As Byte
  C As Byte
End Structure

Dim STvar As Astruct

Clear(STvar)

End
Results with this ASM code for the Clear line

Code: Select all

I0_F1_000023 ; L#MK CLEAR(STVAR)
        CLRF M0_U24,0
But if you add one more variable

Code: Select all

Structure Astruct
  A As Byte
  B As Byte
  C As Byte
  D As Byte
End Structure
Then it clears everything

Code: Select all

I0_F1_000023 ; L#MK CLEAR(STVAR)
        CLRF M0_U32HHH,0
        CLRF M0_U32HH,0
        CLRF M0_U32H,0
        CLRF M0_U32,0
It holds true for Char's and ShortInt's as well. Although a single Word variable in the structure is cleared like normal.

Don't need an immediate fix, as the workaround is easy enough. Just something for your TO-DO list.
Best regards,
DT

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sun Oct 22, 2006 7:34 pm

You can download the latest version of the compiler (1.2.0.2) from

http://www.sfcompiler.co.uk/swordfish/d ... index.html

which should fix the problem for you.

User avatar
Darrel Taylor
Posts: 29
Joined: Wed Oct 04, 2006 4:44 pm
Location: California

Post by Darrel Taylor » Sun Oct 22, 2006 8:55 pm

Yes!

That does indeed fix the problem.

Thanks again David for the great support. :D
Best regards,
DT

Post Reply