Promotional Modifiers

Discuss the Firewing language

Promotional Modifiers

Postby Timbo » Sat May 04, 2013 9:35 pm

Hi,

I'm new to firewing at the language syntax in general, reading the manual I have come across "Promotional Modifiers"

Variable Type Legal
Â
Byte, SByte, Char AsUShort,
UShort, Short


Promotional Modifiers
Â
AsShort, AsUInteger, AsInteger, AsSingle
AsUInteger, AsInteger, AsSingle

Now my question is what exactly does it do and how is it used?

Thanks
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm

Re: Promotional Modifiers

Postby David John Barker » Sun May 05, 2013 8:24 am

Promotional modifiers "promote" a value (for example, a byte varaible) to a word or long word value. For example
Code: Select all
Dim array(8) As Byte
Dim value As array(0).AsUInteger
value = &H01020304

It was originally intended for fast access to blocks within an array. In the example above, array(0) <= 4, array(1) <= 3 and so on.

There is one caveat though when using 16 bit parts. Word and long word data access must fall on even address values. If the start of a byte array "falls" on an odd address value, the compiler will generate an error, as it cannot move a long word value to an odd address. Promotional modifiers can still be useful and you should not have any difficulty with promoting word types. However, this feature was left in the compiler when Firewing was targeting 8 bit devices. If writing new code for 16 parts, I would personally not use this particular feature.
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Promotional Modifiers

Postby Timbo » Mon May 06, 2013 10:39 am

Many thanks for that.

Hopefully soon I will get the hang of it all.

My biggest issue will be when I want to start writing modules and understanding what to include.

Cheers....
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm

Re: Promotional Modifiers

Postby David John Barker » Mon May 06, 2013 6:45 pm

I wouldn't worry about it - just write your code in a normal program block and test. When you have finished:

  • Make all declarations, including subroutines, you want other modules or programs to see "public"
  • Make all declarations, including subroutines, you don't want to be seen "private"
  • Add "module <name>" at the top of the module
  • Add "end module" at the bottom
That's pretty much it to get started with...
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 2 guests

x