Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Error: "Illegal Label (inter)", "Symbol not prev. defined (inter)"

Status
Not open for further replies.

Fordy

New Member
Hi, having some problems with my coursework project.

We were given templates (from the exam board) to build on - they only contain ;**aesthetic placeholders** and the like, as well as start, ;subroutines here, and things like that.

Now, under ;vectors are the lines:
Code:
org	   0000h
goto    start
org	   0004h
goto	   inter
org	   0008h

I know this template to be working, as I tested another example someone had made a previous year, and it assembled fine.

However, when I try to build mine (which has the same lines as above, and as in the known-working)

I get these two errors (only):


Error[113] J:\FIRE.ASM 38 : Symbol not previously defined (inter)
Error[121] J:\FIRE.ASM 189 : Illegal label (inter)


Line 189 refers to the end of the program, where org 0004h should point:
Code:
inter   end

I don't understand what could be different in mine that causes it not to work. I've even tried changing 'inter' for 'somelabel', and a different PC, and different installation (and different version) of MPLAB.



Any tips?
 
Try putting 'end' on the line after 'inter' - like this:

Code:
inter
            end


That's crazy; you're a genius.

I'd already 'fixed' it (had to hand it it) by just removing the offending lines. I'm not using an interrupt at all, so there wasn't really a reason to worry about it overly.


I've just made your suggested change though, and it builds fine - so thanks for that I'll keep it like that for reference if nothing else!


EDIT:
I'll also suggest the template is changed!
 
Last edited:
It's a problem I've had a number of times over the years, and never really understood why - but putting the label on the previous line prevents it.

Is that in general good practice? I've noticed code with labels on previous line before, but personally I've always labelled in-line (not that 'always' is by any means extensive in my case!).
 
It's a problem I've had a number of times over the years, and never really understood why - but putting the label on the previous line prevents it.

The "end" command tells the assembler there's no more code past that point, so I think the assembler assumes the code must all be above that line, ie; if the end command is on a line that line itself is just not assembled.
 
The "end" command tells the assembler there's no more code past that point, so I think the assembler assumes the code must all be above that line, ie; if the end command is on a line that line itself is just not assembled.

It's not just the 'end' directive, it's labels throughout the code (most commonly with a line like 'goto Start' - skipping over ISR space) - I don't think I've ever had the problem specifically with 'end' as I've never used it on the same line as a label.
 
Using a colon :)) right after your labels, this way you can easily identify labels. The 'END' assembler directive is very handy as you can put it anywhere in your code. This way you can have code that will later on be part of your program 'temporary' ignored by the assembler.
 
It's not just the 'end' directive, it's labels throughout the code (most commonly with a line like 'goto Start' - skipping over ISR space) - I don't think I've ever had the problem specifically with 'end' as I've never used it on the same line as a label.

Sorry Nigel I'm not understanding you? Labels must be the first thing to appear on a line, I have never had a problem with MPLAB and labels, but I do always put them at the very start (first char) of a line. I have used labels on empty lines and on lines where there is an instruction after the label, and not seen what you are mentioning? I must be misunderstanding you?
 
Sorry Nigel I'm not understanding you? Labels must be the first thing to appear on a line, I have never had a problem with MPLAB and labels, but I do always put them at the very start (first char) of a line. I have used labels on empty lines and on lines where there is an instruction after the label, and not seen what you are mentioning? I must be misunderstanding you?

I believe what he's suggesting is:

Code:
label
              code

instead of:

Code:
label       code
.


I only noticed the problem wiuth them on the same line with END though.
 
Sorry Nigel I'm not understanding you? Labels must be the first thing to appear on a line, I have never had a problem with MPLAB and labels, but I do always put them at the very start (first char) of a line. I have used labels on empty lines and on lines where there is an instruction after the label, and not seen what you are mentioning? I must be misunderstanding you?

No, you're understanding me :D

'Sometimes' a label at the start of a line (in the very first character space) just doesn't work - I've never been able to find the reason for it, but having the label on it's own line works 100% of the time. This has happened since the pre-Windows days, it's nothing new or specific to MPLAB.

Even more baffling, a label that worked one minute doesn't work after you've edited the code (in a completely different part of the source) - it only happens very occasionally, but it's been bafling me for 20 years or so :D
 
'Sometimes" it is not the actual line that is the problem but the previous line. Also had the problem with an editor that puts the 'backspace' character in the text, so it helps to delete the text before and after the offending line of code and the re-enter it.
 
Wow, I used MPLAB/MPASM since the 90's and have never seen (or remembered seeing) that problem.

Maybe Lourens is right it is something to do with invisible characters? I had another brand C compiler IDE that was terrible for that. All of a sudden code would stop working, and for no reason. Then displaying the text file in a hexeditor would show illegal chars, control characters. I think the compiler IDE would insert these characters into the source on certain mashed keypresses involving the CTL or ALT key, but of course display them as spaces(!) in the source. Mongrel thing.

If you use a newer keyboard that might do stuff automatically (like make control chars?) it might be contributing. I only use the real old "clicky" 1980's style big keyboards, I detest "windows" keyboards and squidgy little keyboards with a vengeance. ;)
 
Wow, I used MPLAB/MPASM since the 90's and have never seen (or remembered seeing) that problem.

I've only seen it a small number of times over the years, to the extent that when it ever happens I've usually totally forgotten about it :D

Maybe Lourens is right it is something to do with invisible characters?

I can't see it?, it happened with plain text editors under DOS (including ones I wrote, which certainly didn't insert any characters), using Notepad under Windows, and latterly using MPLAB.
 
Nigel have reason.
I found the problem using Assembler + Linker (MPLAB IDE 8.92)

Dly10w
pagesel Delay10ms_W
goto Delay10ms_W
or
Dly10w:
pagesel Delay10ms_W
goto Delay10ms_W
correctly compiled.

But:

Dly10w pagesel Delay10ms_W
goto Delay10ms_W
send:
Error[121] : Illegal label (Dly10w)

No illegal characters, because I use TexPad and can discriminate from space and non printable garbage.
Regards and Greetings for Christmas and an Happy New Year
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top