Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » MSPGCC
  • » [Mspgcc-users] memory input 0 is not directly addressable [RSS Feed]

#1 June 16, 2010 06:35:39

Mark R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] memory input 0 is not directly addressable


I'm writing a little bootloader and I am jumping from the interrupt
vector to the relocated interrupted vector with little functions like
this

interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
asm("br &0xfde4" :: );
}

This compiles and works fine. But it is ugly and has a magic number
in the assembly string.

So I would like to parameterize it out of the way:

#define VECTOR_OFFSET (-512)

interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
asm("br %" :: "m" (PORT1_VECTOR + VECTOR_OFFSET));
}

but this gives me an error:
main.c: In function ‘PORT1SR’:
main.c:18: error: memory input 0 is not directly addressable

What does "not directly addressable" mean?

Regards,
Mark
markra...@gmail
--
Mark Rages, Engineer
Midwest Telecine LLC
markra...@midwesttelecine.com

Offline

#2 June 17, 2010 02:27:35

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] memory input 0 is not directly addressable


Compiles and links perfectly on my 12/08 mspgcc.
Somehow the calculation PORT1_VECTOR + VECTOR_OFFSET lets the compiler cough
and does not resolve to either a relocation (to be filled by the linker) or a
discrete value.
Is PORT1_VECTOR known at this point?

JMGross


----- Ursprüngliche Nachricht -----
Von: Mark Rages
An: GCC for MSP430 -http://mspgcc.sf.netGesendet am: 16 Jun 2010 00:35:32
Betreff: memory input 0 is not directly addressable

I'm writing a little bootloader and I am jumping from the interrupt
vector to the relocated interrupted vector with little functions like
this

interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
asm("br &0xfde4" :: );
}

This compiles and works fine. But it is ugly and has a magic number
in the assembly string.

So I would like to parameterize it out of the way:

#define VECTOR_OFFSET (-512)

interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
asm("br %" :: "m" (PORT1_VECTOR + VECTOR_OFFSET));
}

but this gives me an error:
main.c: In function ‘PORT1SR’:
main.c:18: error: memory input 0 is not directly addressable

What does "not directly addressable" mean?

Regards,
Mark
markra...@gmail
--
Mark Rages, Engineer
Midwest Telecine LLC
markra***@*idwesttelecine.com


Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#3 June 17, 2010 04:03:01

Peter B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] memory input 0 is not directly addressable


The value of PORT1_VECTOR + VECTOR_OFFSET is an integer, which is not the
same as an addressable memory location. In gcc4, the parameter to a memory
reference has to be an lvalue.

Try something like:

asm("br %" :: "m" (*(uint16_t*)(PORT1_VECTOR +
VECTOR_OFFSET)));


Peter

On Tue, Jun 15, 2010 at 5:35 PM, Mark Rages <markra***@*mail.com> wrote:

> I'm writing a little bootloader and I am jumping from the interrupt
> vector to the relocated interrupted vector with little functions like
> this
>
> interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
> asm("br &0xfde4" :: );
> }
>
> This compiles and works fine. But it is ugly and has a magic number
> in the assembly string.
>
> So I would like to parameterize it out of the way:
>
> #define VECTOR_OFFSET (-512)
>
> interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
> asm("br %" :: "m" (PORT1_VECTOR + VECTOR_OFFSET));
> }
>
> but this gives me an error:
> main.c: In function ‘PORT1SR’:
> main.c:18: error: memory input 0 is not directly addressable
>
> What does "not directly addressable" mean?
>
> Regards,
> Mark
> markra...@gmail
> --
> Mark Rages, Engineer
> Midwest Telecine LLC
> markra***@*idwesttelecine.com
>
>
>
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users>

Offline

#4 June 18, 2010 02:40:08

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] memory input 0 is not directly addressable


Sure you're right.
But I wonder why he got an error while I don't.
I looked at the generated code and the compiler generated a constant containing
the value (PORT1_VECTOR-512), and the branch brances onto the location pointed
to by this constant.
Of course this isn't what was intended, but it produces no error on my system.
The compiler generates an lvalue. And since it is an input an dnot an output
parameter, the 'lvalue' may be constant too.

here's the example:

#define VECTOR_OFFSET (-512)
interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
asm("br %" :: "m" (PORT1_VECTOR + VECTOR_OFFSET));
}

1659 .stabs "j:r(0,4)",64,0,204,11
1660 .stabn 192,0,0,.LBB25-testThread3
1661 .stabn 224,0,0,.LBE25-testThread3
1662 .Lscope8:
1663 .stabs "",36,0,0,.Lscope8-testThread3
1664 .p2align 1,0
1665 .LC17:
1666 0840 5EFE .short -418
1667 .p2align 1,0
1668 .stabs "PORT1SR:F(0,20)",36,0,218,PORT1SR
1669 .global PORT1SR
1670 .global vector_ffde
1671 .type PORT1SR,@function
1672 /***********************
1673 * Interrupt Service Routine `PORT1SR' at 0xffde
1674 ***********************/
1675 vector_ffde:
1676 PORT1SR:
215:ez3.c ****
216:ez3.c ****
217:ez3.c **** #define VECTOR_OFFSET (-512)
218:ez3.c **** interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR
(void) {
1677 .stabn 68,0,218,.LM198-PORT1SR
1678 .LM198:
1679 /* prologue: naked */
1680 .L__FrameSize_PORT1SR=0x0
219:ez3.c **** asm("br %" :: "m" (PORT1_VECTOR +
VECTOR_OFFSET));
1681 .stabn 68,0,219,.LM199-PORT1SR
1682 .LM199:
1683 /* #APP */
1684 0842 1042 0000 br &.LC17
220:ez3.c **** }
1685 .stabn 68,0,220,.LM200-PORT1SR
1686 .LM200:
1687 /* #NOAPP */
1688
1689 /* epilogue: naked */
1690 .Lfe10:
1691 .size PORT1SR,.Lfe10-PORT1SR
1692 /********* End of function ******/

Of course that's not what was wanted. Using the 'i' constraint instead of the
'm' constraint had had the same result, just without the additional memory
constant:
1681 0840 1042 5EFE br #llo(-418)


With your modification, the compiler generates

1681 0840 1042 5EFE br &-418

which is the intended result.

I still wonder why he got an error message. Maybe PORT1_VECTOR was unknown, in
addition to the wrong addressing mode/parameter type.


JMGross

----- Ursprüngliche Nachricht -----
Von: Peter Bigot
An: GCC for MSP430 -http://mspgcc.sf.netGesendet am: 16.Juni.2010 22:02:52
Betreff: Re: memory input 0 is not directly addressable


The value of PORT1_VECTOR + VECTOR_OFFSET is an integer, which is not the
same as an addressable memory location. In gcc4, the parameter to a memory
reference has to be an lvalue.

Try something like:

asm("br %" :: "m" (*(uint16_t*)(PORT1_VECTOR +
VECTOR_OFFSET)));


Peter

Offline

#5 June 18, 2010 03:19:29

Peter B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] memory input 0 is not directly addressable


I think you don't get the error message because you use gcc3, and the
corresponding code in gcc3 (gcc/stmt.c:expand_asm_operands) only complains
if the value is used as an output. In gcc4
(gcc/gimplify.c:gimplify_asm_expr), the test is refined and an error
produced when the integer value is used as an input as well. Which is good,
if the original source generated undesired code under gcc3.

I had no problems duplicating the problem; PORT1_VECTOR was properly
defined.

Peter

On Thu, Jun 17, 2010 at 1:40 PM, JMGross <msp***@*rossibaer.de> wrote:

>
>
> Sure you're right.
> But I wonder why he got an error while I don't.
> I looked at the generated code and the compiler generated a constant
> containing the value (PORT1_VECTOR-512), and the branch brances onto the
> location pointed to by this constant.
> Of course this isn't what was intended, but it produces no error on my
> system. The compiler generates an lvalue. And since it is an input an dnot
> an output parameter, the 'lvalue' may be constant too.
>
> here's the example:
>
> #define VECTOR_OFFSET (-512)
> interrupt (PORT1_VECTOR) __attribute((naked)) PORT1SR (void) {
> asm("br %" :: "m" (PORT1_VECTOR + VECTOR_OFFSET));
> }
>
> 1659 .stabs "j:r(0,4)",64,0,204,11
> 1660 .stabn 192,0,0,.LBB25-testThread3
> 1661 .stabn 224,0,0,.LBE25-testThread3
> 1662 .Lscope8:
> 1663 .stabs "",36,0,0,.Lscope8-testThread3
> 1664 .p2align 1,0
> 1665 .LC17:
> 1666 0840 5EFE .short -418
> 1667 .p2align 1,0
> 1668 .stabs "PORT1SR:F(0,20)",36,0,218,PORT1SR
> 1669 .global PORT1SR
> 1670 .global vector_ffde
> 1671 .type PORT1SR,@function
> 1672 /***********************
> 1673 * Interrupt Service Routine `PORT1SR' at 0xffde
> 1674 ***********************/
> 1675 vector_ffde:
> 1676 PORT1SR:
> 215:ez3.c ****
> 216:ez3.c ****
> 217:ez3.c **** #define VECTOR_OFFSET (-512)
> 218:ez3.c **** interrupt (PORT1_VECTOR) __attribute((naked))
> PORT1SR (void) {
> 1677 .stabn 68,0,218,.LM198-PORT1SR
> 1678 .LM198:
> 1679 /* prologue: naked */
> 1680 .L__FrameSize_PORT1SR=0x0
> 219:ez3.c **** asm("br %" :: "m" (PORT1_VECTOR +
> VECTOR_OFFSET));
> 1681 .stabn 68,0,219,.LM199-PORT1SR
> 1682 .LM199:
> 1683 /* #APP */
> 1684 0842 1042 0000 br &.LC17
> 220:ez3.c **** }
> 1685 .stabn 68,0,220,.LM200-PORT1SR
> 1686 .LM200:
> 1687 /* #NOAPP */
> 1688
> 1689 /* epilogue: naked */
> 1690 .Lfe10:
> 1691 .size PORT1SR,.Lfe10-PORT1SR
> 1692 /********* End of function ******/
>
> Of course that's not what was wanted. Using the 'i' constraint instead of
> the 'm' constraint had had the same result, just without the additional
> memory constant:
> 1681 0840 1042 5EFE br #llo(-418)
>
>
> With your modification, the compiler generates
>
> 1681 0840 1042 5EFE br &-418
>
> which is the intended result.
>
> I still wonder why he got an error message. Maybe PORT1_VECTOR was unknown,
> in addition to the wrong addressing mode/parameter type.
>
>
> JMGross
>
> ----- Ursprüngliche Nachricht -----
> Von: Peter Bigot
> An: GCC for MSP430 -http://mspgcc.sf.net> Gesendet am: 16.Juni.2010 22:02:52
> Betreff: Re: memory input 0 is not directly addressable
>
>
> The value of PORT1_VECTOR + VECTOR_OFFSET is an integer, which is not the
> same as an addressable memory location. In gcc4, the parameter to a memory
> reference has to be an lvalue.
>
> Try something like:
>
> asm("br %" :: "m" (*(uint16_t*)(PORT1_VECTOR +
> VECTOR_OFFSET)));
>
>
> Peter
>
>
>
>
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users>

Offline

  • Root
  • » MSPGCC
  • » [Mspgcc-users] memory input 0 is not directly addressable [RSS Feed]

Board footer

Moderator control

Enjoy the 19th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support