<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I had some time this weekend (while
beeing grilled by the sun on my balcony) to work on another thing
that did not work correct and that I did not understand (Now I do,
I least I hope ;-)<br>
<br>
As said before in this thread, I wanted to distribute Code in two
different memory areas because this needs to be done so that pic32
startup code works correctly.<br>
<br>
But when I linked my binary the elf-file had always a startup
address somewhere in the wrong memory area.<br>
<br>
This is what I tried:<br>
<br>
procedure reset; assembler; nostackframe; public name'_reset';<br>
asm<br>
.section ".reset,\"ax\",@progbits"<br>
la $k0, _startup<br>
jr $k0 //Jump to startup code<br>
nop<br>
.text<br>
end;<br>
<br>
but this does not what I expected. I thought that the code would
go to the segment I assigned to .reset in the linker script (that
worked) and I also thought that the symbol _reset would point to
this location<br>
<br>
... which did not happen ...<br>
<br>
the symbol _reset will get defined somewhere in the .text segment
even though the code resides in another segment (please see the
generated assembler listing created by inline asm later in this
mail). All in all that makes perfect sense, the compiler is doing
exactly what I wrote but not what I wanted ;-) ;-)<br>
<br>
So I created a 'real' assembler file for the startup code, there i
wrote:<br>
<br>
.section .reset,"ax",@progbits<br>
.set noreorder<br>
.ent _reset<br>
_reset:<br>
la $k0, _startup<br>
jr $k0 # Jump to startup code<br>
nop<br>
<br>
.end _reset<br>
.globl _reset<br>
<br>
this worked perfect, now the linker uses the address of the _reset
procedure in the correct memory area as the startup address.<br>
<br>
So is there a way I can get this behaviour in inline assembler?<br>
<br>
Something like: <br>
<br>
procedure reset; assembler; nostackframe; public name '_reset';
section '.reset,"ax",@progbits';<br>
<br>
???<br>
<br>
TnX,<br>
<br>
Michael<br>
<br>
<br>
---- generated assemblerfile:<br>
<br>
.section .text.n_pic32mx1xxfxxxb_$$_reset<br>
.balign 4<br>
.globl PIC32MX1XXFXXXB_$$_RESET<br>
.type PIC32MX1XXFXXXB_$$_RESET,@function<br>
PIC32MX1XXFXXXB_$$_RESET:<br>
.globl _reset<br>
.type _reset,@function<br>
_reset:<br>
.ent PIC32MX1XXFXXXB_$$_RESET<br>
<br>
.section .reset,"ax",@progbits<br>
la $k0, _startup<br>
jr $k0<br>
nop<br>
<br>
.section .text.n_pic32mx1xxfxxxb_$$_reset<br>
# path: mipsel/<br>
# file: pic32mx_start.inc<br>
# indx: 2<br>
.Ll3:<br>
jr $ra<br>
nop<br>
.set macro<br>
.set reorder<br>
.end PIC32MX1XXFXXXB_$$_RESET<br>
.Lt2:<br>
.Le1:<br>
.size PIC32MX1XXFXXXB_$$_RESET, .Le1 -
PIC32MX1XXFXXXB_$$_RESET<br>
.Ll4:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Am 03.06.13 08:07, schrieb Michael Ring:<br>
</div>
<blockquote cite="mid:51AC32BF.7030703@michael-ring.org" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">This version worked,<br>
<br>
thank you for your help!<br>
<br>
Michael<br>
<br>
Am 02.06.13 23:20, schrieb Jeppe Græsdal Johansen:<br>
</div>
<blockquote cite="mid:51ABB71B.8050608@j-software.dk" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Den 02-06-2013 23:15, Michael Ring
skrev:<br>
</div>
<blockquote cite="mid:51ABB5F2.6080305@michael-ring.org"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Unfortunately that does not seem
to work (or I use it wrong):<br>
<br>
This procedure:<br>
<br>
procedure _general_exception_handler; assembler;
nostackframe; public name '_GENERAL_EXCEPTION_HANDLER';<br>
asm<br>
.section "reset"<br>
sdbbp 0;<br>
.Lloopb:<br>
b .Lloopb<br>
end;<br>
<br>
translates to:<br>
<br>
.section
.text.n_pic32mx1xxfxxxc_$$__general_exception_handler<br>
.balign 4<br>
.globl PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER<br>
.type
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER,@function<br>
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER:<br>
.globl _GENERAL_EXCEPTION_HANDLER<br>
.type _GENERAL_EXCEPTION_HANDLER,@function<br>
_GENERAL_EXCEPTION_HANDLER:<br>
.ent
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER<br>
<br>
.section reset<br>
sdbbp 0<br>
.Lj11:<br>
b .Lj11<br>
jr $ra<br>
nop<br>
.set macro<br>
.set reorder<br>
.end
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER<br>
.Lt3:<br>
.Le2:<br>
.size
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER, .Le2 -
PIC32MX1XXFXXXC_$$__GENERAL_EXCEPTION_HANDLER<br>
.Ll8:<br>
<br>
which creates an assembler error:<br>
<br>
/Users/ring/devel/fpc/rtl/units/mipsel-embedded/pic32mx1xxfxxxc.s:94:
Error: operation combines symbols in different segments<br>
<br>
the error is from the .size line.<br>
<br>
<br>
<br>
Am 02.06.13 22:51, schrieb Jeppe Græsdal Johansen:<br>
</div>
<blockquote cite="mid:51ABB040.70305@j-software.dk"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Den 02-06-2013 22:41, Michael
Ring skrev:<br>
</div>
<blockquote cite="mid:51ABADE9.2010307@michael-ring.org"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi, perhaps I am overseeing a simple solution for my
problem:<br>
<br>
On the pic32 there are two flash areas, one at 0x9d000000
for the main program and another at 0xbfc00000 that is
called Boot Flash. On reset the program starts in the boot
flash at the first address.<br>
<br>
I have written the startup code for the chips now but I
need to distribute some procedures between the two memory
areas, for obvious reasons I must have some code at
address 0xbfc00000 or the chip will not boot correctly
;-).<br>
<br>
My thought was now to tweak the linker script in the same
way the original linker scripts of pic32 work:<br>
<br>
MEMORY<br>
{<br>
kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH
= 0x80000<br>
kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH
= 0x490<br>
}<br>
<br>
SECTIONS<br>
{<br>
.reset _RESET_ADDR :<br>
{<br>
KEEP(*(.reset))<br>
KEEP(*(.reset.startup))<br>
} > kseg1_boot_mem<br>
}<br>
<br>
In assembler I can then simply write: <br>
.section .reset,code and<br>
.section .reset.startup,code<br>
<br>
and then the code, this will automagically end up in the
kseg1_boot_mem, but this does not work with the inline
assembler. Any ideas on how to do this the correct way? Is
there something more intelligent than to write a plain
assembler file?<br>
<br>
TnX,<br>
<br>
Michael<br>
</blockquote>
<br>
You should be able to use<br>
.section ".reset" </blockquote>
<br>
</blockquote>
<br>
Try<br>
<br>
procedure _general_exception_handler; assembler; nostackframe;
public name '_GENERAL_EXCEPTION_HANDLER';<br>
asm<br>
.section "reset"<br>
sdbbp 0;<br>
.Lloopb:<br>
b .Lloopb<br>
.text<br>
end;<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
fpc-devel maillist - <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>