Shop OBEX P1 Docs P2 Docs Learn Events
PNUT error message that will drive you NUTZ!!! — Parallax Forums

PNUT error message that will drive you NUTZ!!!

I was bringing an old program forward to test (back when we just had one counter). I made a typo and 'waitcnt' became 'waitct' instead of waitct1'. Instead of complaining about a bad mnemonic, it gave me an 'undefined symbol' error for the local label above the waitct and highlighted that label in the instruction several above the bad mnemonic.
con
	SYS_CLK = 50_000_000
	BAUD_RATE = 115_200

	RX_PIN = 63
	TX_PIN = 62

dat
	orgh	0



	org	0
cog_entry
'       waitbob	
	setb	outb, #TX_PIN
	setb	dirb, #TX_PIN

'*******************************************************
'********* TEST CODE - PUT YOUR CODE HERE **************
' ***** try some input/output
loopback
		
		call	#rcv_char
		mov	tx_char, rx_char
		call	#send_char
		jmp	#loopback

'********* TEST CODE - REPLACE WITH YOUR CODE ***********
'********************************************************

'*******************************************************************************
' Get one character from the input port.
' Input none
' Changes parm, temp, temp1, temp2
' Output parm
'*******************************************************************************

rcv_char                  
		setedg	#%0_10_000000 | RX_PIN		'select negative edge on p63

		polledg				'clear edge detector
		waitedg				'wait for start bit

		waitx	bit_time		'wait for middle of 1st data bit

		rep	@.rep,#8		'ready for 8 bits
		testb 	inb,#RX_PIN	wc	'sample rx
		rcr	rx_char,#1		'rotate bit into byte
		waitx	bit_time	'wait for middle of nth data bit
.rep
		shr	rx_char,#32-8		'justify received byte
		ret


'*******************************************************************************
' Output a single character to the tx_pin.
' executes in COG mode
' Input: txchar - character to be sent
' Changes parm, temp1, temp2
' Output none             
'*******************************************************************************

send_char	setb	tx_char,#8
		shl	tx_char,#1
		getct 	timer

		rep	@.txrep,#10
		testb	 tx_char,#0 wz
		setbnz	outb,#TX_PIN
		addct1	timer,bit_time
		waitct1
		shr	tx_char,#1
.txrep
		ret


bit_time	long	SYS_CLK / BAUD_RATE
tx_char		res	1
timer		res	1
rx_char		res	1
		fit	$1F0

If you change the waitct1 to waitct in the send_char routine, when you compile, you get an undefined symbol error on the 'rep @.txrep,#10' - yeah, I spent about 30 minutes trying to figure out what was undefined about that.

It happens on v3, v4, v5 and v6, so it's not the recent changes.

While testing, I also found that you can put a bad mnemonic in the code at other places and PNUT just ignores it. Put something like 'waitbob' at the top of the code and PNUT blows right past it, no errors, no code generated, just skips it and moves along.

Not a show stopper, but just beware of crazy error messages!

Comments

  • ElectrodudeElectrodude Posts: 1,660
    edited 2015-11-23 19:54
    mindrobots wrote: »
    While testing, I also found that you can put a bad mnemonic in the code at other places and PNUT just ignores it. Put something like 'waitbob' at the top of the code and PNUT blows right past it, no errors, no code generated, just skips it and moves along.

    That last part is correct behavior. It creates a label "waitbob". You confused yourself by indenting it. Try a "jmp #waitbob" and you'll see.
  • AribaAriba Posts: 2,690
    Yes PNUT does not identify a wrong mnemonic, it just takes them as labels. So you get often a error at the first parameter, if the mnemonic is wrong.
    Mnemonics with no parameters seem to be more worth as in your example.

    A solution would be that a label always needs to start at begin of a line, if not at begin PNUT expect that it is a mnemonic.

    Andy
  • Andy, your solution is the assumption my brain made. :)

    The handling on .txrep still is strange until you realize that the bad mnemonic creates a global label which takes .txrep out of scope for the rep.
  • These are all syntactical problems. Nothing a good syntax highlighter can't fix, one with block indicators like Prop Tool has, but also in PASM blocks. Also something that can be debugged using Prop Tool's (or BST's) ctrl+click-on-word feature, where it shows you the type (var, dat, pub, obj, etc.) and address of an identifier.
Sign In or Register to comment.