Shop OBEX P1 Docs P2 Docs Learn Events
Gear Emulator — Parallax Forums

Gear Emulator

dr hydradr hydra Posts: 212
edited 2010-06-16 02:04 in Propeller 1
How accurate is the gear emulator:

look at the code below...what would x1 equal after the program is ran

CON
······· _clkmode······· = xtal1 + pll8x
······· _xinfreq······· = 10_000_000 + 3000
PUB ex01
cognew(@ex01A, 0)
DAT
ORG 0
ex01A
······· add x1,x2
·······
x1····· long 5000
x2····· long· 2000
FIT 496

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-06-16 00:50
    dr hydra said...
    look at the code below...what would x1 equal after the program is ran
    I don't know gear (except by name) but there is no after. At least not for a while until x1 gets into non-nop instruction range or the cog blocks on e.g. a bad waitvid. Even then, it's unlikely that this would generate a sequence stopping cog 1 [noparse]:)[/noparse]

    Why don't you tell us?

    Post Edited (kuroneko) : 6/16/2010 1:26:45 AM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-06-16 01:02
    Never seen

     _xinfreq        = 10_000_000 + 3000
    

    What's that about?

    Jim
  • dr hydradr hydra Posts: 212
    edited 2010-06-16 01:22
    x1 should equal 7000...right...not 9000
  • BradCBradC Posts: 2,601
    edited 2010-06-16 01:27
    that depends entirely on what instruction x1 long 5000 translates to and what garbage you have floating in memory after that.

    Try putting a jmp #$ after the add and see what happens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I mean, if I went around sayin' I was an emperor just because some moistened bint had lobbed a scimitar at me they'd put me away!"
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-16 01:27
    dr hydra said...
    x1 should equal 7000...right...not 9000
    Nothing wrong with 9000, I haven't seen what's on the stack but what is loaded into the cog suggests at least one run-through (nothing is stopping execution). Then maybe some flags have changed which would block the cog on a waitvid ($FFF9FFFF stack markers).
    BradC said...
    Try putting a jmp #$ after the add and see what happens.
    7000 [noparse]:)[/noparse]

    Post Edited (kuroneko) : 6/16/2010 1:34:15 AM GMT
  • dr hydradr hydra Posts: 212
    edited 2010-06-16 01:32
    BradC

    The jmp#$ works...but why
  • BradCBradC Posts: 2,601
    edited 2010-06-16 01:56
    dr hydra said...
    BradC

    The jmp#$ works...but why

    Because it stops the cog running off and executing random data.

    Picture it this way. The cog is your car. You are driving on an incomplete overhead freeway (the cog is executing the code). Suddenly you find the road stops as its only half built and your car falls off the end (you have no more valid code after the add). What happens to your car?

    Now see the same scenario with a big flashing roadblock where the road ends (jmp #$). You stop your car and sit there. You don't die.

    Without the roadblock, the cog merrily goes along its way trying to drive over everything in front of it, executing random code that has been loaded from the cog and doing unpredictable things. Put the road block in front of it and it sits there spinning its wheels waiting for something to happen.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I mean, if I went around sayin' I was an emperor just because some moistened bint had lobbed a scimitar at me they'd put me away!"
  • BradCBradC Posts: 2,601
    edited 2010-06-16 01:58
    dr hydra said...

    The jmp#$ works...but why
    Sorry, it also occurs to me the jmp #$ is non obvious.. it translates to this.

    here:    jmp #:here
    
    



    So it puts the cog into an endless spinning loop doing nothing at full speed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I mean, if I went around sayin' I was an emperor just because some moistened bint had lobbed a scimitar at me they'd put me away!"
  • dr hydradr hydra Posts: 212
    edited 2010-06-16 02:04
    BradC

    Thank you..thank you...I spent all day working on this
Sign In or Register to comment.