Shop OBEX P1 Docs P2 Docs Learn Events
String vs DAT — Parallax Forums

String vs DAT

Ray0665Ray0665 Posts: 231
edited 2011-03-28 17:15 in Propeller 1
I have been using DAT statements for all my strings rather than the inline string() statement for some time now. And tonight with some idle time on my hands I was wondering if using the DAT statement had any advantage over the inline. My gut was saying yes but then there is this matter of hub ram access so I just wasn't sure. Only one way to find out.... Two identical loops so the only difference is string() vs DAT
test it... Now I know for sure.
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  count = 10000
obj
  pst: "Parallax serial Terminal"
dat
  msg byte "text",0

pub main| t,t1,t2,s
pst.start(115200)
repeat 50
   pst.str(string(13,"first "))
   t := cnt
   repeat count
'     s := string("text")
     s := @msg
   t1 := cnt - t
   pst.dec(t1)

   pst.str(string("   second "))
   t := cnt
   repeat count
     s := string("text")
'     s := @msg
   t2 := cnt - t
   pst.dec(t2)
pst.str(string(13,"Avg Difference (in clock cycles):"))
pst.dec((t2-t1)/count)
pst.newline

Sign In or Register to comment.