Shop OBEX P1 Docs P2 Docs Learn Events
Assembly differences between PNut and Flexgui - Page 2 — Parallax Forums

Assembly differences between PNut and Flexgui

2»

Comments

  • evanhevanh Posts: 15,240
    This fails to loop properly. There is a +$400 byte offset ($100 longwords) to the branch distance, or it might be +$3fc bytes ($ff longwords). If you comment the JMP #loop1 it'll work correctly using the JMP #$400.
    dat	org
    	jmp	#loop1
    
    
    	orgh	$400
    loop1
    	drvnot #56
    	waitx ##25_000_000/20
    
    	long	0[5000]
    
    	drvnot #57
    	waitx ##25_000_000/20
    
    	jmp #loop1
    	jmp #$400
    
    
  • Does it also work if you comment out the
    long	0[5000]
    
    ?
  • evanh wrote: »
    This fails to loop properly. There is a +$400 byte offset ($100 longwords) to the branch distance, or it might be +$3fc bytes ($ff longwords). If you comment the JMP #loop1 it'll work correctly using the JMP #$400.
    dat	org
    	jmp	#loop1
    
    
    	orgh	$400
    loop1
    	drvnot #56
    	waitx ##25_000_000/20
    
    	long	0[5000]
    
    	drvnot #57
    	waitx ##25_000_000/20
    
    	jmp #loop1
    	jmp #$400
    
    

    Like previous test results this code also works fine if I go back to V34L.

  • evanhevanh Posts: 15,240
    edited 2020-05-05 07:42
    whicker wrote: »
    Does it also work if you comment out the
    long	0[5000]
    
    ?
    It crashes because the +$400 offset makes the branch end up beyond the end of the program ... That said, if you have the remnant of a functioning version in hubRAM that isn't getting overwritten by the new download then, when run, it'll hit that old code and loop back just fine.

  • evanhevanh Posts: 15,240
    Here's my more long-winded version that always erases hubRAM before the test.
    dat	org
    
    'backup first part
    	setq2	#9
    	rdlong	0, ##@loop1
    
    'backup second part
    	setq2	#9
    	rdlong	10, ##@hubcode2
    
    'erase entire 512 kB hubRAM
    	wrfast	#0, #0
    	rep	@.rend, ##512*1024/4
    	wflong	#0
    .rend
    	rdfast	#0, #0
    
    'restore first part
    	setq2	#9
    	wrlong	0, ##@loop1
    
    'restore second part
    	setq2	#9
    	wrlong	10, ##@hubcode2
    
    'and away we go ...
    	wrpin	#0, #56|1<<6
    	jmp	#loop1
    
    
    
    	orgh	$400
    loop1
    	drvnot	#56
    	waitx	##25_000_000/20
    
    	long	0[1000]
    hubcode2
    	drvnot	#57
    	waitx	##25_000_000/20
    	jmp	#loop1
    	jmp	#$400
    
    
Sign In or Register to comment.