Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic Multiplication — Parallax Forums

PropBasic Multiplication

FriedVFriedV Posts: 77
edited 2011-09-26 03:20 in Propeller 1
@Bean,
either I make a very stupid mistake or there is something wrong
with multiplication in PropBasic?
' ----------------------------------------------------------------------
' File......  MotCntCtrl.pbas
' Author....  fgvissel  25.09.2011
' ======================================================================

' ----- Device Settings ------------------------------------------------
  DEVICE P8X32A, XTAL1, PLL16X
  XIN 6_250_000

  tix           var long      
  tox           var long

PROGRAM Start

Start:
' setup code
watch tix
watch tox
Main:

tix = _FREQ / 1000            'period = 1msec tix = 100.000

tox = tix * 3         '<<<<<<<<<<<<<<<<<<<<<<<< doesn't work?

do
 loop

END

Comments

  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-09-25 12:41
    What does it do?
  • BeanBean Posts: 8,129
    edited 2011-09-25 18:51
    Yes, there is a bug that makes the compiler hang-up for awhile at multiply. It will continue and generate the proper code.
    The bug has been fixed, but I don't have a new revision ready yet.

    Bean
  • FriedVFriedV Posts: 77
    edited 2011-09-25 21:21
    Not only does the compiler hang on multiply (not everytime BTW) the result is also wrong.
    * 3 -> *1, *2 ok, * 4 ok, *6 -> *2
    Fried
  • BeanBean Posts: 8,129
    edited 2011-09-26 03:20
    FriedV,
    I'll check into it.
    The mult should not hang for powers of 2 (2, 4, 8, 16, etc).

    The mult result may be incorrect for any constant value with 2 bits set.

    For now the workaround is to multiply by a variable. You can use__param1 if you are not using it for a subroutine.

    Instead of:
    tox = tix * 3 
    

    Use
    __param1 = 3
    tox = tix * 3
    

    Bean
Sign In or Register to comment.