Shop OBEX P1 Docs P2 Docs Learn Events
PASM value in a range? — Parallax Forums

PASM value in a range?

jazzedjazzed Posts: 11,803
edited 2009-06-10 17:03 in Propeller 1
Hi.

I have a situation where I need to find out if a number is in a given range in PASM.
The most straight forward way to do this is with cmp. Surely there is a better/faster way.

comploop
  rdlong       num,   par  wz    ' get non-zero number
  if_z  jmp    #comploop
  movd         wrval, num        ' prepare for write from cog ptr

  ' optimize this comparison ? can it be done with 3 instructions ?
  cmp          num,   start wc   ' number < start ?
  if_b  jmp    #dosomething
  cmp          adr,   end wc     ' number > end ?
  if_a  jmp    #dosomething

wrval   mov    0-0,   ptr
  wrlong       dirb,  par        ' command complete
  jmp          #comploop

dosomething
  ' yada yada yada
  wrlong       dirb,  par        ' command complete
  jmp          #comploop



Any ideas? TIA.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230

Comments

Sign In or Register to comment.