Shop OBEX P1 Docs P2 Docs Learn Events
the execution time of BS2 of each instruction — Parallax Forums

the execution time of BS2 of each instruction

ArchiverArchiver Posts: 46,084
edited 2000-07-15 21:48 in General Discussion
To build further on Tracy's data, here are some measurements made
with my Time Machine (TM-1):

HIGH 1...146 usec


INPUT 1...143 usec


PAUSE 1...1,233 usec
PAUSE 2...2,236 usec


SLEEP 1...2,324,133 usec *


PULSOUT 4,1...216 usec
PULSOUT 4,2...219 usec
PULSOUT 4,10...239 usec


GOTO b
.
b:
...255 usec


GOSUB b
...787 usec
.
b:
RETURN


FOR i = 1 TO 1
NEXT
...825 usec


FOR i = 1 TO 2
NEXT
...1582 usec


FOR i = 1 TO 10
NEXT
...7691 usec


i = 1...181 usec


i = x...196 usec


i = z.LOWBYTE...196 usec


(when x <> y i.e. fall through)
IF x = y THEN b
...366 usec


(when x = y i.e. branch)
IF x = y THEN b
.
b:
...475 usec


BRANCH x,[noparse][[/noparse]b,c,d]
when x = 0...334 usec
when x = 1...385 usec
when x = 2...439 usec
when x = 3 (not in value list)...297 usec


LOOKUP x,[noparse][[/noparse]0,1,2],y
when x = 0...576 usec
when x = 1...577 usec
when x = 2...576 usec
when x = 3 (not in value list)...565 usec


LOOKDOWN x,[noparse][[/noparse]0,1,2],y
when x = 0...1287 usec
when x = 1...1286 usec
when x = 2...1286 usec
when x = 3 (not in value list)...1279 usec


All of the indicated times reflect the actual program statement
execution time as opposed to the statement's effective time. For
example, the HIGH 1 instruction took a total of 146 usec from
start to finish, but I/O 1 may have exhibited an asserted high
slightly earlier than the completion of the statement's processing.

* Note the ~2.3 granularity of the SLEEP command.

Want your own TM-1? The Scenix SX-18 code is posted at

http://home.earthlink.net/~parkiss/

Can't or don't want to roll your own SX-18? Contact me off the
list for a programmed chip and 40 MHz clock (< US$20).

For those who may be interested, here's the Stamp program used to
generate the timing figures above. It uses 1 Stamp pin to send and
receive commands to the TM-1, and a second Stamp pin to "frame" Stamp
instructions for measurement purposes.

'==========================================================================
' TM-1 command code constants
'==========================================================================
report_timers CON 0
simple_timer CON 1
repeating_timer CON 2
edge_term_timer CON 3
pulse_timer CON 4
cycle_timer CON 5
char_to_LCD CON 6
cmd_to_LCD CON 7

'==========================================================================
' BS-2 I/O pin constants
'==========================================================================
edge_1 CON 0 ' edge_1 input on TM-1
timer_pin CON 1 ' serial line to/from TM-1

'==========================================================================
' Serial comm constants (38400, non-inverted, open baudmode for xmit)
'==========================================================================
out_baud CON 6+32768
baud CON 6

'==========================================================================
' Program variables
'==========================================================================
toggled VAR WORD ' receives toggle counter from TM-1
o1 VAR toggled.HIGHBYTE
o0 VAR toggled.LOWBYTE
mult VAR WORD ' receives HO word of time counter
t3 VAR mult.HIGHBYTE
t2 VAR mult.LOWBYTE
usecs VAR WORD ' receives LO word of time counter
t1 VAR usecs.HIGHBYTE
t0 VAR usecs.LOWBYTE
xtoggled VAR WORD
xo1 VAR xtoggled.HIGHBYTE
xo0 VAR xtoggled.LOWBYTE
xmult VAR WORD
xt3 VAR xmult.HIGHBYTE
xt2 VAR xmult.LOWBYTE
xusecs VAR WORD
xt1 VAR xusecs.HIGHBYTE
xt0 VAR xusecs.LOWBYTE
i VAR BYTE ' utility variable
x VAR BYTE
y VAR BYTE

start:
PAUSE 200 ' allow TM-1 initialization

' In this example, a pulse timer is used to derive very accurate
' times for Stamp instructions. The TM-1 is commanded to measure
' the duration of a high pulse applied to its edge_1 input (or a
' low pulse applied to its edge_2 input). The pulses originate
' from the Stamp itself and surround one or more instructions to
' determine their execution time.


LOW edge_1 ' start edge_1 off low
SEROUT timer_pin,out_baud,[noparse][[/noparse]pulse_timer] ' pulse timer command
INPUT timer_pin

' First, measure the duration of a pulse caused by a HIGH then LOW
HIGH edge_1 ' first edge of pulse
LOW edge_1 ' second edge of pulse
PAUSE 75 ' ensure 50 msec pulse complete
SEROUT timer_pin,out_baud,[noparse][[/noparse]report_timers] ' get timer values
SERIN timer_pin,baud,[noparse][[/noparse]o1,o0,t3,t2,t1,t0]
DEBUG CR,"First case:",CR,"(",dec mult," * 65536) + ",dec usecs

' Now insert something between the HIGH and LOW and measure again
SEROUT timer_pin,out_baud,[noparse][[/noparse]pulse_timer] ' pulse timer command
INPUT timer_pin
HIGH edge_1 ' first edge of pulse
'*************************************************

lookdown x,[noparse][[/noparse]0,1,i,2],y ' or whatever to be measured

'*************************************************
LOW edge_1 ' second edge of pulse
PAUSE 75 ' ensure 50 msec pulse complete
SEROUT timer_pin,out_baud,[noparse][[/noparse]report_timers] ' get timer values
SERIN timer_pin,baud,[noparse][[/noparse]xo1,xo0,xt3,xt2,xt1,xt0]
DEBUG CR,CR,"Second case:",CR,"(",dec xmult," * 65536) + ",dec xusecs

' The difference between the two times is the command's execution time
IF usecs > xusecs THEN borrow
xusecs = xusecs - usecs: xmult = xmult - mult: GOTO showXTime

borrow: xusecs = usecs - xusecs: xmult = xmult - 1 - mult

showXTime:
DEBUG CR,CR,"usec for execution:",CR
IF xmult = 0 THEN showUsecs
DEBUG "(",DEC xmult," * 65536) + "
showUsecs:
DEBUG DEC xusecs


On 10 Jul 00 at 18:03, baker_bai@c... wrote:

> BS2 is a interpreter chip, Could anyone tell me the exection time of
> each BS2 instruction ?...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-07-13 02:14
    unsubcribe
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-15 13:13
    Sure, pls do add them to your page--might as well keep 'em together
    somewhere (also, isn't one of the list regulars maintaining a FAQ?).


    Regards,

    Steve


    On 15 Jul 00 at 16:48, Tracy Allen wrote:

    > Hi Steve,
    > I just wanted to say that these timing values are very interesting.
    > I wonder if you are going to put these on your web site, where I
    > could link to them, or if I could put them on my web site under the
    > timings (with attribution of course, and a link to the time
    > machine!).
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-15 21:48
    Hi Steve,
    I just wanted to say that these timing values are very interesting. I
    wonder if you are going to put these on your web site, where I could link
    to them, or if I could put them on my web site under the timings (with
    attribution of course, and a link to the time machine!).

    -- Tracy


    ---original message--->
    To build further on Tracy's data, here are some measurements made
    with my Time Machine (TM-1):
    HIGH 1...146 usec
    INPUT 1...143 usec
    PAUSE 1...1,233 usec
    PAUSE 2...2,236 usec
    SLEEP 1...2,324,133 usec *
    PULSOUT 4,1...216 usec
    PULSOUT 4,2...219 usec
    PULSOUT 4,10...239 usec

    GOTO b
    b: ...255 usec

    GOSUB b
    b:RETURN ...787 usec

    FOR i = 1 TO 1
    NEXT ...825 usec

    FOR i = 1 TO 2
    NEXT...1582 usec

    FOR i = 1 TO 10
    NEXT...7691 usec

    i = 1...181 usec

    i = x...196 usec

    i = z.LOWBYTE...196 usec

    (when x <> y i.e. fall through)
    IF x = y THEN b ...366 usec

    (when x = y i.e. branch)
    IF x = y THEN b
    b: ...475 usec

    BRANCH x,[noparse][[/noparse]b,c,d]
    when x = 0...334 usec
    when x = 1...385 usec
    when x = 2...439 usec
    when x = 3 (not in value list)...297 usec

    LOOKUP x,[noparse][[/noparse]0,1,2],y
    when x = 0...576 usec
    when x = 1...577 usec
    when x = 2...576 usec
    when x = 3 (not in value list)...565 usec

    LOOKDOWN x,[noparse][[/noparse]0,1,2],y
    when x = 0...1287 usec
    when x = 1...1286 usec
    when x = 2...1286 usec
    when x = 3 (not in value list)...1279 usec


    All of the indicated times reflect the actual program statement
    execution time as opposed to the statement's effective time. For
    example, the HIGH 1 instruction took a total of 146 usec from
    start to finish, but I/O 1 may have exhibited an asserted high
    slightly earlier than the completion of the statement's processing.

    * Note the ~2.3 granularity of the SLEEP command.

    Want your own TM-1? The Scenix SX-18 code is posted at

    http://home.earthlink.net/~parkiss/

    Can't or don't want to roll your own SX-18? Contact me off the
    list for a programmed chip and 40 MHz clock (< US$20).

    For those who may be interested, here's the Stamp program used to
    generate the timing figures above. It uses 1 Stamp pin to send and
    receive commands to the TM-1, and a second Stamp pin to "frame" Stamp
    instructions for measurement purposes.

    '==========================================================================
    ' TM-1 command code constants
    '==========================================================================
    report_timers CON 0
    simple_timer CON 1
    repeating_timer CON 2
    edge_term_timer CON 3
    pulse_timer CON 4
    cycle_timer CON 5
    char_to_LCD CON 6
    cmd_to_LCD CON 7

    '==========================================================================
    ' BS-2 I/O pin constants
    '==========================================================================
    edge_1 CON 0 ' edge_1 input on TM-1
    timer_pin CON 1 ' serial line to/from TM-1

    '==========================================================================
    ' Serial comm constants (38400, non-inverted, open baudmode for xmit)
    '==========================================================================
    out_baud CON 6+32768
    baud CON 6

    '==========================================================================
    ' Program variables
    '==========================================================================
    toggled VAR WORD ' receives toggle counter from TM-1
    o1 VAR toggled.HIGHBYTE
    o0 VAR toggled.LOWBYTE
    mult VAR WORD ' receives HO word of time counter
    t3 VAR mult.HIGHBYTE
    t2 VAR mult.LOWBYTE
    usecs VAR WORD ' receives LO word of time counter
    t1 VAR usecs.HIGHBYTE
    t0 VAR usecs.LOWBYTE
    xtoggled VAR WORD
    xo1 VAR xtoggled.HIGHBYTE
    xo0 VAR xtoggled.LOWBYTE
    xmult VAR WORD
    xt3 VAR xmult.HIGHBYTE
    xt2 VAR xmult.LOWBYTE
    xusecs VAR WORD
    xt1 VAR xusecs.HIGHBYTE
    xt0 VAR xusecs.LOWBYTE
    i VAR BYTE ' utility variable
    x VAR BYTE
    y VAR BYTE

    start:
    PAUSE 200 ' allow TM-1 initialization

    ' In this example, a pulse timer is used to derive very accurate
    ' times for Stamp instructions. The TM-1 is commanded to measure
    ' the duration of a high pulse applied to its edge_1 input (or a
    ' low pulse applied to its edge_2 input). The pulses originate
    ' from the Stamp itself and surround one or more instructions to
    ' determine their execution time.


    LOW edge_1 ' start edge_1 off low
    SEROUT timer_pin,out_baud,[noparse][[/noparse]pulse_timer] ' pulse timer command
    INPUT timer_pin

    ' First, measure the duration of a pulse caused by a HIGH then LOW
    HIGH edge_1 ' first edge of pulse
    LOW edge_1 ' second edge of pulse
    PAUSE 75 ' ensure 50 msec pulse complete
    SEROUT timer_pin,out_baud,[noparse][[/noparse]report_timers] ' get timer values
    SERIN timer_pin,baud,[noparse][[/noparse]o1,o0,t3,t2,t1,t0]
    DEBUG CR,"First case:",CR,"(",dec mult," * 65536) + ",dec usecs

    ' Now insert something between the HIGH and LOW and measure again
    SEROUT timer_pin,out_baud,[noparse][[/noparse]pulse_timer] ' pulse timer command
    INPUT timer_pin
    HIGH edge_1 ' first edge of pulse
    '*************************************************

    lookdown x,[noparse][[/noparse]0,1,i,2],y ' or whatever to be measured

    '*************************************************
    LOW edge_1 ' second edge of pulse
    PAUSE 75 ' ensure 50 msec pulse complete
    SEROUT timer_pin,out_baud,[noparse][[/noparse]report_timers] ' get timer values
    SERIN timer_pin,baud,[noparse][[/noparse]xo1,xo0,xt3,xt2,xt1,xt0]
    DEBUG CR,CR,"Second case:",CR,"(",dec xmult," * 65536) + ",dec xusecs

    ' The difference between the two times is the command's execution time
    IF usecs > xusecs THEN borrow
    xusecs = xusecs - usecs: xmult = xmult - mult: GOTO showXTime

    borrow: xusecs = usecs - xusecs: xmult = xmult - 1 - mult

    showXTime:
    DEBUG CR,CR,"usec for execution:",CR
    IF xmult = 0 THEN showUsecs
    DEBUG "(",DEC xmult," * 65536) + "
    showUsecs:
    DEBUG DEC xusecs


    On 10 Jul 00 at 18:03, baker_bai@c... wrote:

    > BS2 is a interpreter chip, Could anyone tell me the exection time of
    > each BS2 instruction ?...
Sign In or Register to comment.