Shop OBEX P1 Docs P2 Docs Learn Events
flexspin compiler for P2: Assembly, Spin, BASIC, and C in one compiler - Page 41 — Parallax Forums

flexspin compiler for P2: Assembly, Spin, BASIC, and C in one compiler

13839414344122

Comments

  • TonyB_TonyB_ Posts: 2,178
    edited 2020-02-27 16:53
    Rayman wrote: »
    I moved some code to hubexec and got an error on this:
    tjz     arg6,#loop              'if no points exit with new px,py
    

    Says that tjz can't cross hub/cog boundary.

    Still trying to understand this... Seems like djnz and tjz can't jump back into cog space, right?
    But, plain JMP can?

    Fastspin says
    error: tjnz branch crosses LUT/COG boundary
    when 9-bit immediate is not big enough for jump and nothing to do with boundary crossing.
  • evanhevanh Posts: 15,915
    There's plenty of slightly off errors. One I get a lot is "unexpected end of line" when I was missing a closing ")" on an immediate equation.

    Oddly, there is no Fastspin error when I have too many closing ")".

  • evanhevanh Posts: 15,915
    edited 2020-02-27 22:38
    cgracey wrote: »
    The TJZ immediate branch can only go +/- 255 instructions. It's unlikely that cog and hubexec code will be that close together.
    Even that doesn't work crossing back from hubexec.

    I think it just generates NOPs until back to address $400 where it will fetch from the FIFO again. Just does weird stuff, depending on the offset.

  • RaymanRayman Posts: 14,646
    whicker wrote: »
    You can be evil and do multi-line with brackets { }:
    CON
      #0, Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver, Grey, Red, Lime, Yellow, Blue, Fuchsia, {
      }Aqua, White, Grey0, NavyBlue, DarkBlue, Blue3, Blue1, DarkGreen, DeepSkyBlue4, DodgerBlue3, DodgerBlue2, {
      }Green4, SpringGreen4, Turquoise4, DeepSkyBlue3, DodgerBlue1, Green3, SpringGreen3, DarkCyan, LightSeaGreen
    

    Actually, I just noticed this in garryj's code:
    CON 'mouse/kb cons
    '------------------------------------------------------------------------------
    ' Event types copied from the usb KbM host object CON block
            #0, NO_EVENT, USB_ERROR, DEV_UNKNOWN, KB_READY, M_READY, KBM_READY
            DEV_DISCONNECT, USB_DBG_INFO, M_DATA
    

    Guess the trick is to leave off the comma at the end of the line...
  • Yep. And you can do this to skip a range of values:
    '------------------------------------------------------------------------------
    ' HID Class Requests (v1.11 HID Device Class Definition, Section 7.2):
    '------------------------------------------------------------------------------
            #$01, HID_GET_REPORT, HID_GET_IDLE, HID_GET_PROTO[6] ' $04 - $08 reserved
            HID_SET_REPORT, HID_SET_IDLE, HID_SET_PROTO
    
  • evanhevanh Posts: 15,915
    evanh wrote: »
    cgracey wrote: »
    The TJZ immediate branch can only go +/- 255 instructions. It's unlikely that cog and hubexec code will be that close together.
    Even that doesn't work crossing back from hubexec.
    I've worked it out I think. When relative branching from hubexec back into cogexec/lutexec, it does similar to going to hubexec. When going to hubexec all addresses are longword scaled. Eg: A relative address resolved to $401 actually lands you at hubram address $404. That generally works fine as long as hub code is longword aligned.

    Well, doing the same again going back to cogram means each increment steps four cogram locations at a time! It can only land on addresses that have least two bits as zero. :(

  • evanhevanh Posts: 15,915
    edited 2020-02-28 23:48
    So here we go - Using long relative branching between hubexec and cogexec with three cases of TJZ ##
    DAT
    ORG  0
    		mov	0, #0
    		fltl	#56 | 5<<6
    		wrpin	#0, #56 | 5<<6
    		drvl	#56 | 2<<6
    '-------- Copy lut code into position --------
    		setq2	#(lut_end - lut_start - 1)	'copy length, in longwords
    		rdlong	(lut_start - $200), ##@lut_start
    
    stopper		jmp	#cogcode
    
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    
    filling		long	$				'hack to setup following quad word alignment of "cogcode"
    ORGF  ((filling+1)/4+1)*4
    
    cogcode
    		mov	stopper, #0
    		waitx	pause
    		outnot	#56
    '		jmp	#lutcode
    '		long	$fd900000 | ((lutcode-$-1)*4)&$fffff	'JMP  #lutcode
    
    		augs	#lutcode-$-2
    		long	$fb940000 | (lutcode-$-1)&$1ff		'TJZ  0, ##lutcode
    
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    
    
    pause		long	5_000_000
    
    		long	$
    		long	$
    		long	hubcode
    
    
    ORGH  $600
    
    '--------------------------------------------------------------------
    ORG  $300
    lut_start
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    
    lutcode
    		waitx	pause
    		outnot	#57
    '		jmp	#hubcode				'  -  absolute encoding
    '		long	$fd900000 | ((hubcode-$-1)*4)&$fffff	'JMP  #hubcode  -  relative encoding
    
    		augs	#hubcode-$-2
    		long	$fb940000 | (hubcode-$-1)&$1ff		'TJZ  0, ##hubcode
    
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    lut_end
    '--------------------------------------------------------------------
    
    
    ORGH
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    
    hubcode
    		waitx	pause
    		outnot	#58
    '		jmp	#cogcode					'  -  absolute encoding
    '		long	$fd900000 | (cogcode-$-4)&$fffff		'JMP  #cogcode  -  relative encoding
    
    		augs	#(cogcode-$-8)/4
    		long	$fb940000 | ((cogcode-$-4)/4)&$1ff		'TJZ  0, ##cogcode
    
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    		jmp	#$
    
    		long	$
    		long	cogcode
    		long	lutcode
    		long	hubcode
    

    EDIT: Removed some dross
    EDIT2: Improve lutram code copy generalisation
  • RaymanRayman Posts: 14,646
    edited 2020-02-28 14:40
    I'm not sure I like the way that fastspin only error checks code that is actually used when compiled...

    This is fine for a code user, who is just using proven code.
    But, not so good for a code developer who may add methods without testing them...
  • Rayman wrote: »
    But, not so good for a code developer who may add methods without testing them...

    Well, one's not supposed to add untested methods, yet we all do it anyways...
    OTOH, Spin is really not good for writing self-contained test code (unless you're just testing the public interface of an object).
  • RaymanRayman Posts: 14,646
    edited 2020-03-02 19:12
    Just noticed something interesting...

    The local variables in a method I was continuously calling were preserved between calls.

    But, when I made a copy of this method (with slightly different name),
    the local variables were no longer preserved.

    Obviously, these variables should be in a VAR section (they are now).
    Still, I'm surprised it worked the way it was...

    PS: ersmith: Hope you're not sick again!
  • Rayman wrote: »
    PS: ersmith: Hope you're not sick again!

    Ditto that!

    Eric has been walkout for about a week now, which is unusual. Historically he has been incredibly responsive to bug reports, often spinning a new version of FlexGUI within hours. I’m hoping he is buried in a project and making some really obscene $$$. :)

    @ersmith We miss ya, ol’ Bean! Write when you can!
  • David BetzDavid Betz Posts: 14,516
    edited 2020-03-04 13:15
    I wondered why Eric hadn't been online for a while as well so I sent him email and got a response from his wife saying he had been taken to the hospital a week ago. He is still there waiting for the doctors to determine the cause of his illness. She said she wasn't sure when he would be back.
  • evanhevanh Posts: 15,915
    Definitely a big GET WELL SOON for Eric.
  • RaymanRayman Posts: 14,646
    I was afraid of that... Get well soon Eric!
  • cgraceycgracey Posts: 14,152
    I hope the doctors figure out what Eric needs and he gets better.
  • David,
    Thanks for the update. I tried emailing him and got no reply.
    Hope they figure out what's up and get him on the road to recovery soon.
  • Cluso99Cluso99 Posts: 18,069
    Eric,
    Wishing you a speedie recovery. We miss you.
  • +1. May you be up and around soon.
  • @ersmith I'm putting this up here for when you are "back in the saddle again". There isn't any sense of urgency here.

    There is an interesting issue I found in FlexBASIC 4.1.3 on a Win10 machine targetting a P2-EVAL Rev B board. If you (accidently) create two SUBs with the same name in the same file, you will get a "child killed: segmentation violation" error when you try to compile it. Here is the output of one such attempt:
    "d:/Flex2Gui/flexgui/bin/fastspin" -2 -l -O1 -I "d:/Flex2Gui/flexgui/include" -I "d:/Flex2Gui/flexgui/P2 Libs"  "d:/Flex2Gui/flexgui/P2 Libs/GPS-RTC-Serial-TestP2.bas"
    Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
    Version 4.1.3 Compiled on: Feb  5 2020
    child killed: segmentation violation
    Finished at Thu Mar  5 14:09:34 2020
    
    This is very clearly a case of the programmer shooting himself squarely in the foot (I'm quite good at that), but it would be helpful to have an error thrown that is a bit more descriptive if its possible.
  • RaymanRayman Posts: 14,646
    Sure hope Eric comes back soon...
  • Rayman wrote: »
    Sure hope Eric comes back soon...
    I haven't heard anything from either Eric or his wife lately although I sent her the comments from this forum after I posted about his illness and she said he was touched. I'll post as soon as I hear anything.

  • I miss you Eric. Please beat that bug that's got you down.
  • Thanks everyone for your good wishes. I'm still in hospital but feeling much better. We hope this trend will continue and I'll be out of here soon. Until then my wifi access is a bit wonky so please forgive delays getting back to you.

  • Glad to hear you are feeling better Eric.
  • RaymanRayman Posts: 14,646
    Good news! Thanks for lettings us know. Hang in there!
  • Good to hear Eric!
    No worries about delays in replies, your health is more important.
  • “Please forgive delays in getting back to you...”

    Eric, you are simply amazing! I really hope to meet you some day and shake your hand!

    Get better, Ol’ Bean. We miss you!

  • cgraceycgracey Posts: 14,152
    edited 2020-03-09 02:19
    Glad you're doing well, Eric! You must be tempted, somewhat, to get a laptop going in the hospital. As you get better, your brain will hunger for something to do.
  • Cluso99Cluso99 Posts: 18,069
    Great news to hear you are on the mend. Meanwhile, take it easy and let your system heal :smiley:
  • Get well eric!
Sign In or Register to comment.