PASM - cmp instruction
lanternfish
Posts: 366
I am having a few problems to get the following section of code to run properly.
If C0_NextCOG = 1 then appears to jump to non code address $005F.
If C0_NextCOG = 0 then appears to jump to code address $0013.
EDIT :IsItMe is address $003
What I want to happen is that C0_ActiveCog (=1 in this case; located at $1FFC in Main Memory) is compared with the value of C0_ThisCOG (= 0 in this case). If not equal then loop and test again. If equal then continue with rest of code,
I am testing code in Gear.
Thanks in advance for any help.
The complete code is:
:SignalCOGs wrbyte C0_NextCOG, C0_COGSync 'C0_NextCOG = 1 for :IsItMe loop test 'COGSync Address = $1FFC :IsItMe rdbyte C0_ActiveCOG, C0_COGSync 'Get current decimating cog cmp C0_ActiveCOG, C0_ThisCOG wz 'Is it this COG? if_nz jmp :IsItMe 'Jump if it isn't. Else do ...
If C0_NextCOG = 1 then appears to jump to non code address $005F.
If C0_NextCOG = 0 then appears to jump to code address $0013.
EDIT :IsItMe is address $003
What I want to happen is that C0_ActiveCog (=1 in this case; located at $1FFC in Main Memory) is compared with the value of C0_ThisCOG (= 0 in this case). If not equal then loop and test again. If equal then continue with rest of code,
I am testing code in Gear.
Thanks in advance for any help.
The complete code is:
{{SVGA Scaler 800 x 600 to 400 x 300}} PUB Main {Launch COG's} 'coginit(7, @InitCOG0, 0) 'Launch COG 7 'coginit(6, @InitCOG0, 0) 'Launch COG 6 'coginit(5, @InitCOG0, 0) 'Launch COG 5 'coginit(4, @InitCOG0, 0) 'Launch COG 4 'coginit(3, @InitCOG3, 0) 'Launch COG 3 'coginit(2, @InitCOG2, 0) 'Launch COG 2 'coginit(1, @InitCOG1, 0) 'Launch COG 1 coginit(0, @InitCOG0, 0) 'Launch COG 0 CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 DAT {COG0 Pixel Decimation} org 0 InitCOG0 mov dira, C0_FIFOReadPin 'Set P7 output (FIFO RD pulse +ve) mov outa, #0 'P7 Low :SignalCOGs wrbyte C0_NextCOG, C0_COGSync 'C0_NextCOG = 0 for :IsItMe loop test 'COGSync Address = $1FFC :IsItMe rdbyte C0_ActiveCOG, C0_COGSync 'Get current decimating cog cmp C0_ActiveCOG, C0_ThisCOG wz 'Is it this COG? if_nz jmp :IsItMe 'Jump if it isn't. Else do ... :InitDecimation mov C0_COGPointer, #$40 mov C0_PixelCounter, #400 :ReadFIFO xor outa, C0_FIFOReadPin 'P7 High 'mov C0_RGB1Value, ina 'Read RGB value from FIFO and store at address RGBAddress mov C0_RGB1Value, C0_PseudoIna 'Store pseudo-ina data at address RGBAddress xor outa, C0_FIFOReadPin 'P7 Low nop xor outa, C0_FIFOReadPin 'P7 High 'mov C0_RGB2Value, ina 'Read RGB value from FIFO and store at address RGBAddress mov C0_RGB2Value, C0_PseudoIna 'Store pseudo-ina data at address RGBAddress xor outa, C0_FIFOReadPin 'P7 Low :DecimatePixel add C0_RGB1Value, C0_RGB2Value 'Add 1st and 2nd RGB longs shr C0_RGB1Value, #1 'Divide by 2 (get average of two longs) movd :WriteRGB, C0_COGPointer 'Prepare self modifying code nop 'to write RGB data to COG RAM :WriteRGB mov 0-0, C0_RGB1Value 'Write RGB data to COG RAM add C0_COGPointer, #1 'Point to next COG RAM address djnz C0_PixelCounter, #:ReadFIFO 'If C0_PixelCounter not zero then repeat @ ReadFIFO :SignalNextCOG wrbyte C0_NextCOG, C0_COGSync 'COGSynch Address = $1FFF: HUB RAM Cog Synch address :RGB2HUBInit mov C0_COGPointer, #$40 mov C0_PixelCounter, #400 :ReadCOGRAM movs :RGBRead, C0_COGPointer 'Prepare self modifying code nop 'to read RGB long from COG RAM :RGBRead mov C0_RGB1Value, 0-0 'Read RGB long from COG RAM :Write2HUB wrlong C0_RGB1Value, C0_HUBPointer 'Write RGB data to HUB RAM add C0_COGPointer, #1 'Next COG RAM address add C0_HUBPointer, #1 'Point to next HUB RAM long address djnz C0_PixelCounter, #:ReadCOGRAM 'If C0_PixelCounter not zero then repeat @ DecimateLoop { add C0_HUBPointer, C0_HUBCountInc djnz C0_LineCounter, #:IsItMe mov C0_HUBPointer, #0 mov C0_LineCounter, #8 } :ForeverLoop jmp #:ForeverLoop 'Loop forever C0_COGPointer long $40 C0_PixelCounter long 400 C0_PseudoIna long $00_2A_15_2A C0_FIFOReadPin long |< 7 C0_RGB1Value long 0 C0_RGB2Value long 0 C0_HUBPointer long $0 C0_COGSync long $1FFC C0_ThisCOG long 0 C0_NextCOG long 0 C0_ActiveCOG long 0 C0_HUBCountInc long 1599 C0_LineCounter long 8
Comments
-Phil
Don't I feel foolish! I'm frequently forgetting the # when it is most needed.
Thanks
Don't feel bad: I do it all the time, too. It's a habit from other assemblers which has become set, I'm afraid. So, after entering a bit of PASM code, I always do a search for jmps in my program, and check each of them to make sure I included the # where it's needed.
-Phil
I have to say I am really enjoying the challenge of both PASM and the great flexibilty of the Propeller.
Thanks again for the assist.