Self modifying quirk
This one has been plaguing me for the past few days. I'm going to chalk it up to a bug in the silicon or the assembler. Not sure which. In my code, I need to do a computed jump. I have finally figured out what the issue is but it seems strange that I would have to do it this way. I'm just putting this up for others to reference. This is some sample code that does nothing like my real program but exhibits the same quirk. In short, if I modify this instruction, things don't work:
If I try to modify this instruction, things work:
Any thoughts on why this is happening?
-Jack
test01 jmp 0-0
If I try to modify this instruction, things work:
test01 jmp #BB
Any thoughts on why this is happening?
-Jack
PUB Start(address) cognew(@test00,address) DAT test00 mov dira,#255 mov temp,#0 mov jumpPoint,#8 add jumpPoint,#BB 'contains the correct address movs test01,jumpPoint nop test01 jmp #BB 'BB is replaced with the correct address and it works 'jmp 0-0 'doesn't work. Never makes it to the code below BB add temp,#1 add temp,#1 add temp,#1 add temp,#1 add temp,#1 add temp,#1 add temp,#1 add temp,#1 add temp,#1 ' should jump to here add temp,#1 add temp,#1 mov outa,temp ' should display 3 jmp #test00 temp res 1 jumpPoint res 1
Comments
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
mov tmp, #0
mov tmp, 0
do different things.
My question ... you already reserved a variable to calculate the address. So, why do you do a movs at all? You can also jump to an address stored in a variable:
jmp jumpPoint
This way you don't need the movs and the nop!
and it works. I thought that I had tried that.
MagIO2,
It hadn't occurred to me that I could do it that way. That's great. It reduces the complexity and increases the speed of my program! I'm definitely going to do it that way now!
-Jack