Jump to content
IGNORED

Help a newbie out...


ZippyOasys

Recommended Posts

3 hours ago, carlsson said:

IntyBASIC uses # for 16-bit variables.

 

Whoops! That is absolutely right!  I'm just used to seeing it mangled by the compiler in the generated assembly code.  Sorry about that.

 

(I have fixed the previous post.)

 

3 hours ago, carlsson said:

Doesn't the fixed point mode already handle fractions? From the manual:

 

#A = 1.5 (translated as $8001, of which the high byte is the fraction)

#A = #A+.#B

 

@nanochess has mentioned in the past that he will phase out that feature because it is sub-optimal and cumbersome, so he recommended not to rely on it.  I do not believe there is a replacement for it.

 

The built-in feature switches the upper and lower bytes of the number.  It was originally recommended by @GroovyBee as a way to optimize fractional values for sprite handling.  Since the STIC's X and Y registers have the sprite position in the lower byte, then copying a 16-bit fraction in reverse notation into a register would actually copy the integer portion without swapping.

 

However, handling fixed point arithmetic then becomes cumbersome because you need to handle the carry bit of the fractional portion in the upper byte — whereas in a normal fraction any carry would naturally be applied to the integer portion as it propagates upwards through the value.

 

When working in Assembly Language, there are various techniques that you can exploit to optimize arithmetic operations, and you can chose to employ them when necessary, as you please; but in IntyBASIC the compiler would have to generate general-purpose code every time it needs to operate on fractional values.

 

Personally, not only is it counter-intuitive to represent a fraction in reverse, it is my opinion that the cost of swapping the values when accessing the integer portion (which occurs seldom) is cheaper than the cost of having to manage carry bits and overflow on every operation on the full fractional value (which occurs more often).

 

3 hours ago, carlsson said:

I've never used it, so I don't know how it works if you mix 16-bit fixed point and regular 8-bit variables.

 

I've used it, and I have suggested it in the past to others, but stopped when @nanochess recommended against it.

 

      -dZ.

 

Link to comment
Share on other sites

Oh, I wasn't aware it is about to become an obsoleted feature. Then I understand if we want to come up with other ways to represent fractional numbers, more general purpose and that the compiler won't stop supporting eventually.

 

On the other hand, if a future version of the compiler will stop supporting the current syntax, perhaps all we need to do is to come up with a better implementation and use a different syntax instead of by hand reinventing the wheel as I feel it would be to do all that by hand in your program.

Link to comment
Share on other sites

16 hours ago, carlsson said:

Oh, I wasn't aware it is about to become an obsoleted feature. Then I understand if we want to come up with other ways to represent fractional numbers, more general purpose and that the compiler won't stop supporting eventually.

 

I agree.  However, it wasn't clear to me if Oscar intended to add a different feature to the language to replace it.

 

16 hours ago, carlsson said:

On the other hand, if a future version of the compiler will stop supporting the current syntax, perhaps all we need to do is to come up with a better implementation and use a different syntax instead of by hand reinventing the wheel as I feel it would be to do all that by hand in your program.

 

That is par for the course around these parts.  Personally, I think scanning hand-controllers, animating sprites, and playing sound effects, etc. are (or at least should be treated as) solved problems.  Yet, all that there is available are particular use-case specific implementations or generic guidance rather than either direct language support, or re-usable library modules.  Everyone ends up re-inventing the wheel every time.

 

Add fixed-point arithmetic to that list.  Do you want to volunteer to write an easy-to-use language extension for fixed point arithmetic?  I have some macros I use on my programs, I could clean them up and share them.

 

     -dZ.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...