[BUG] Variable address + offset in asm statement

Post your requests and ideas on the future development of mikroPascal.
Author
Message
Ric
Posts: 44
Joined: 01 Mar 2007 10:35
Location: Italy

[BUG] Variable address + offset in asm statement

#1 Post by Ric » 12 Mar 2007 13:35

Code: Select all

program Test;

var
  MyArray: array[0..7] of Byte;

begin

  // Trick the optimizer into thinking we use MyArray
  MyArray := MyArray;

  asm
    MOVF    MyArray+1, W
    MOVWF   MyArray+0
    MOVFF   MyArray+2, MyArray+3
  end;

end.
This is the assembler code generated for a PIC18F4455/4550:

Code: Select all

;  Assembly code generated by mikroVirtualMachine - V. 5.0.0.3
;  Date/Time: 12/03/2007 13.15.38
;  Info: http://www.mikroe.com


; ADDRESS	OPCODE	ASM
; ----------------------------------------------
$0000	$EF04	F000			GOTO	_main
$0008	$	_main:
;Test.ppas,4 :: 			MyArray: array[0..7] of Byte;
;Test.ppas,11 :: 			MOVF    MyArray+1, W
$0008	$5000	    			MOVF	MYARRAY+1, W, 0
;Test.ppas,12 :: 			MOVWF   MyArray+0
$000A	$6E00	    			MOVWF	MYARRAY+0, 0
;Test.ppas,13 :: 			MOVFF   MyArray+2, MyArray+3
$000C	$C000	F000			MOVFF	MYARRAY+2, MYARRAY+3
;Test.ppas,14 :: 			end;
$0010	$	Test_L_0:
;Test.ppas,16 :: 			end.
$0010	$D7FF	    			BRA	$
Notice how MyArray+0, MyArray+1, MyArray+2 and MyArray+3 have all been translated as $00! No errors, no warnings, just all offsets silently thrown down the kitchen sink.

The same thing happens with MyArray declared as ABSOLUTE: if MyArray's address is $50, "MOVFF MyArray+2, MyArray+3" becomes "$C050 $F050" (instead of "$C052 $F053").

Curiously enough, compiler-generated labels (STACK_0 and the like) are handled correctly, i.e. if STACK_0+0 is $00, STACK_0+1 is $01; this made the above misbehaviour a lot harder to track, because assembling machine code was definitely the last thing I expected to go wrong.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: [BUG] Variable address + offset in asm statement

#2 Post by zristic » 12 Mar 2007 16:28

Sorry Ric, we cannot provide you support for assembly. This is primarly a Pascal compiler, we cannot cover all possible acrobatics you can do in assembly syntax.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: [BUG] Variable address + offset in asm statement

#3 Post by janni » 12 Mar 2007 19:47

Ric wrote:Notice how MyArray+0, MyArray+1, MyArray+2 and MyArray+3 have all been translated as $00! No errors, no warnings, just all offsets silently thrown down the kitchen sink.
Try using _MyArray+0, _MyArray+1, etc. Somewhere on the way of making the mP better the syntax has changed, but the compiler still accepts variables without the uderscore. The effects you've seen...

Ric
Posts: 44
Joined: 01 Mar 2007 10:35
Location: Italy

Re: [BUG] Variable address + offset in asm statement

#4 Post by Ric » 13 Mar 2007 13:31

zristic wrote:Sorry Ric, we cannot provide you support for assembly. This is primarly a Pascal compiler, we cannot cover all possible acrobatics you can do in assembly syntax.
If "MOVLW label+offset" with "offset" being an integer numeric literal (a syntax seen quite often in compiler-generated code) looks like "doing acrobatics in assembler syntax" to you, I sincerely wonder what does not. NOPs, maybe? Image

Seriously, zristic, I was not doing anything weird in that code, less than ever violating assembler syntax.

Ric
Posts: 44
Joined: 01 Mar 2007 10:35
Location: Italy

Re: [BUG] Variable address + offset in asm statement

#5 Post by Ric » 13 Mar 2007 13:59

janni wrote:Try using _MyArray+0, _MyArray+1, etc.
This works! :D Thanks a lot, janni.
janni wrote:Somewhere on the way of making the mP better the syntax has changed, but the compiler still accepts variables without the uderscore.
This is actually proof that there's a problem with the assembler: it should either not recognize MyArray as a valid label, or support the old syntax by generating correct code. Unless, of course, it purposedly replicates a bug from some earlier version, in which case a warning message should be issued.
"Should", of course, implies "in a perfect world"...

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: [BUG] Variable address + offset in asm statement

#6 Post by zristic » 13 Mar 2007 13:59

Ric wrote:Seriously, zristic, I was not doing anything weird in that code, less than ever violating assembler syntax.
You should study the "Instruction set summary" chapter in datasheet for your pic to see what are legal syntax elements in assembly. Then, come back here and say whether you wrote acrobatics or not.

ASM expansion macros is something that MPLAB does well, therefore, if you want to write fast and readable assembly then please refer to MPLAB.

If you want us to write a compiler for assembly, then you will have to wait until we have nothing else to do.

Sorry.

Ric
Posts: 44
Joined: 01 Mar 2007 10:35
Location: Italy

Re: [BUG] Variable address + offset in asm statement

#7 Post by Ric » 13 Mar 2007 14:39

From what I could gather by looking around in the forum, zristic, you are a good technician and a helpful person. Please, don't waste your reputation by replying nonsense in a thread you didn't even bother to read, about something you don't have a clue about.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#8 Post by janni » 13 Mar 2007 15:04

Ric wrote:This is actually proof that there's a problem with the assembler: it should either not recognize MyArray as a valid label, or support the old syntax by generating correct code. Unless, of course, it purposedly replicates a bug from some earlier version, in which case a warning message should be issued.
"Should", of course, implies "in a perfect world"...
Yea, a perfect world...

The mE team is racing ahead trying to deliver more and more following user requests. There is little time to close the holes left by rapid improvement, and belive me, however I don't like it, most users are satisfied by this approach.

The actual developers in mE are pressed between the management directives and user demands and I'm not surprised that it shows sometimes on the forum. Please don't let it carry you away.

I'd personally prefer safe compiler against rich one, but I realize that I'm not a typical customer. So I've temporarily :) stopped to ask for things I'd like unless it's a critical issue.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: [BUG] Variable address + offset in asm statement

#9 Post by zristic » 13 Mar 2007 15:07

Ric wrote:From what I could gather by looking around in the forum, zristic, you are a good technician and a helpful person. Please, don't waste your reputation by replying nonsense in a thread you didn't even bother to read, about something you don't have a clue about.
You are on a wrong path. I do not know what you want to prove about yourself?

Donald Shimoda
Posts: 553
Joined: 27 Feb 2006 17:00
Location: Argentina
Contact:

#10 Post by Donald Shimoda » 13 Mar 2007 15:10

janni wrote: I'd personally prefer safe compiler against rich one, but I realize that I'm not a typical customer. So I've temporarily :) stopped to ask for things I'd like unless it's a critical issue.
I agree woth you. Typical customer of mikro seems like hobbyst, i feel the same. I develop huge projects with large chunks of code.

I dont agree with your other comments. Dont think they must choice between enhance or fix. I undesrtand the priority must be fix, but theres many things not fixed from version 5.03. Critical for me, i undrestand, maybe is not critical for you.

Best regards.
Donald Shimoda.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#11 Post by janni » 13 Mar 2007 15:22

Donald Shimoda wrote: Typical customer of mikro seems like hobbyst
Whatever drives the sales... We may not like it, but it's the reality on which mE management bases their policy.
Critical for me, i undrestand, maybe is not critical for you.
That's generally true, however I suspect that our expectations are close enough :D .

ColaCola
Posts: 2
Joined: 21 May 2008 10:47

#12 Post by ColaCola » 21 May 2008 10:55

Hi there,

I have been experiencing the same sort of problem as Ric.

I tried using _MyArray+0, _MyArray+1, etc and it worked great for me to, so maybe Ric is right and this is proof that there is a problem with the assembler. Also, if it is the case that tis does purposely replicate a bug then there defiantly should be a warning message issued!

BaCaRdi
Posts: 236
Joined: 21 Feb 2008 02:19

#13 Post by BaCaRdi » 27 May 2008 06:55

A lot of these type issues can be solved by simply having a sticky in the bugs / "work-arounds" forum, in the least, it would solve allot of these type issues. There are many of these issues, ME seem to change things and not mention them and the users suffer. Aren't we the ones that matter?? Besides, shouldn't all this be in the manual, speaking of such, when was the last update to it?

I have had an issue with a glcd that has been from the start of my purchase, which to date has not been resolved. I have posted replies to the so-called support system here, and months and months go by and no responses.

Come on guys, customer service should be your priority, not bashing people on the forums, and off-handed remarks from staff members. People come into the forums in desperation, so already their patients are thin. Most try and try over and over again, before even coming into the support system, and find out something was changed, or it was a bug.


I will tell you this, I love your products and appreciate effort, I know it is hard dealing with the public. But this is part of the support system ME needs to revamp. Without us you do not exist, and really why not do all you can to make most people happy. I know us hobbyist aren't on the engineers level, but I would love to see what percentage of sales are to the hobbyist. I think even ME would be surprised.

Kind regards,
-Marc
[size=109][color=Red][b]Error[/b]: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...[/color][/size]
[url=http://www.bacardiware.com]Information Underground[/url]

Donald Shimoda
Posts: 553
Joined: 27 Feb 2006 17:00
Location: Argentina
Contact:

#14 Post by Donald Shimoda » 27 May 2008 14:21

BaCaRdi wrote: Come on guys, customer service should be your priority,
[...]
I will tell you this, I love your products and appreciate effort, I know it is hard dealing with the public. But this is part of the support system ME needs to revamp. Without us you do not exist, and really why not do all you can to make most people happy. I know us hobbyist aren't on the engineers level, but I would love to see what percentage of sales are to the hobbyist. I think even ME would be surprised.
-Marc
Hehe, deja vou? :P I pronuncied the sames word a lot time ago. I suggest you dont do it again. Many people becomes hungry with ctitics. ;)

Btw, i share your opinion and i think ME will dont.

Best regards.
Donald Shimoda.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#15 Post by zristic » 27 May 2008 15:07

I suggest you dont do it again. Many people becomes hungry with ctitics.
Feel free to express your opinion, we are open to user comments and suggestions. Also, discard what malicious people say.

Post Reply

Return to “mikroPascal Wish List”