mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 04:26:13 +02:00
+ implementation of avr rtl helpers
+ avr: fixed writing of constants in assembler * avr: fixed reading of constants in assembler * avr: determine used registers at procedure exit properly * changed project name to ppavr git-svn-id: branches/avr@17032 -
This commit is contained in:
parent
ad9956022c
commit
7b9276ae8a
@ -110,7 +110,7 @@ unit agavrgas;
|
|||||||
top_reg:
|
top_reg:
|
||||||
getopstr:=gas_regname(o.reg);
|
getopstr:=gas_regname(o.reg);
|
||||||
top_const:
|
top_const:
|
||||||
getopstr:='#'+tostr(longint(o.val));
|
getopstr:=tostr(longint(o.val));
|
||||||
top_ref:
|
top_ref:
|
||||||
if o.ref^.refaddr=addr_full then
|
if o.ref^.refaddr=addr_full then
|
||||||
begin
|
begin
|
||||||
|
@ -1070,12 +1070,12 @@ unit cgcpu;
|
|||||||
begin
|
begin
|
||||||
LocalSize:=current_procinfo.calc_stackframe_size;
|
LocalSize:=current_procinfo.calc_stackframe_size;
|
||||||
a_adjust_sp(list,LocalSize);
|
a_adjust_sp(list,LocalSize);
|
||||||
|
regs:=rg[R_INTREGISTER].used_in_proc-paramanager.get_volatile_registers_int(pocall_stdcall);
|
||||||
|
|
||||||
for reg:=RS_R0 to RS_R31 do
|
for reg:=RS_R0 to RS_R31 do
|
||||||
if reg in regs then
|
if reg in regs then
|
||||||
list.concat(taicpu.op_reg(A_POP,newreg(R_INTREGISTER,reg,R_SUBWHOLE)));
|
list.concat(taicpu.op_reg(A_POP,newreg(R_INTREGISTER,reg,R_SUBWHOLE)));
|
||||||
|
|
||||||
regs:=rg[R_INTREGISTER].used_in_proc-paramanager.get_volatile_registers_int(pocall_stdcall);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ the framepointer cannot be omitted on avr because sp
|
{ the framepointer cannot be omitted on avr because sp
|
||||||
|
@ -333,13 +333,6 @@ Unit raavrgas;
|
|||||||
BuildReference(oper);
|
BuildReference(oper);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AS_HASH: { Constant expression }
|
|
||||||
Begin
|
|
||||||
Consume(AS_HASH);
|
|
||||||
BuildConstantOperand(oper);
|
|
||||||
end;
|
|
||||||
|
|
||||||
(*
|
|
||||||
AS_INTNUM,
|
AS_INTNUM,
|
||||||
AS_MINUS,
|
AS_MINUS,
|
||||||
AS_PLUS:
|
AS_PLUS:
|
||||||
@ -348,16 +341,18 @@ Unit raavrgas;
|
|||||||
{ This must absolutely be followed by ( }
|
{ This must absolutely be followed by ( }
|
||||||
oper.InitRef;
|
oper.InitRef;
|
||||||
oper.opr.ref.offset:=BuildConstExpression(True,False);
|
oper.opr.ref.offset:=BuildConstExpression(True,False);
|
||||||
if actasmtoken<>AS_LPAREN then
|
|
||||||
|
{ absolute memory addresss? }
|
||||||
|
if actopcode in [A_LDS,A_STS] then
|
||||||
|
BuildReference(oper)
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
ofs:=oper.opr.ref.offset;
|
ofs:=oper.opr.ref.offset;
|
||||||
BuildConstantOperand(oper);
|
BuildConstantOperand(oper);
|
||||||
inc(oper.opr.val,ofs);
|
inc(oper.opr.val,ofs);
|
||||||
end
|
end;
|
||||||
else
|
|
||||||
BuildReference(oper);
|
|
||||||
end;
|
end;
|
||||||
*)
|
|
||||||
AS_ID: { A constant expression, or a Variable ref. }
|
AS_ID: { A constant expression, or a Variable ref. }
|
||||||
Begin
|
Begin
|
||||||
{ Local Label ? }
|
{ Local Label ? }
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<Title Value="pp"/>
|
<Title Value="ppavr"/>
|
||||||
</General>
|
</General>
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
<Item1 Name="default" Default="True"/>
|
<Item1 Name="default" Default="True"/>
|
||||||
@ -74,6 +74,9 @@
|
|||||||
<ConfigFile>
|
<ConfigFile>
|
||||||
<StopAfterErrCount Value="50"/>
|
<StopAfterErrCount Value="50"/>
|
||||||
</ConfigFile>
|
</ConfigFile>
|
||||||
|
<CompilerMessages>
|
||||||
|
<UseMsgFile Value="True"/>
|
||||||
|
</CompilerMessages>
|
||||||
<CustomOptions Value="-davr"/>
|
<CustomOptions Value="-davr"/>
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
|
150
rtl/avr/avr.inc
150
rtl/avr/avr.inc
@ -18,10 +18,150 @@
|
|||||||
{$asmmode gas}
|
{$asmmode gas}
|
||||||
|
|
||||||
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
Procedure SysInitFPU;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure fpc_cpuinit;
|
procedure fpc_cpuinit;
|
||||||
begin
|
begin
|
||||||
SysInitFPU;
|
SysInitFPU;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{$IFNDEF INTERNAL_BACKTRACE}
|
||||||
|
{$define FPC_SYSTEM_HAS_GET_FRAME}
|
||||||
|
function get_frame:pointer;assembler;nostackframe;
|
||||||
|
asm
|
||||||
|
end;
|
||||||
|
{$ENDIF not INTERNAL_BACKTRACE}
|
||||||
|
|
||||||
|
|
||||||
|
{$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
|
||||||
|
function get_caller_addr(framebp:pointer):pointer;assembler;
|
||||||
|
asm
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
|
||||||
|
function get_caller_frame(framebp:pointer):pointer;assembler;
|
||||||
|
asm
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$define FPC_SYSTEM_HAS_SPTR}
|
||||||
|
Function Sptr : pointer;assembler;
|
||||||
|
asm
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InterLockedDecrement (var Target: longint) : longint;
|
||||||
|
var
|
||||||
|
sreg : byte;
|
||||||
|
begin
|
||||||
|
{ block interrupts }
|
||||||
|
asm
|
||||||
|
in r0,0x3f
|
||||||
|
st sreg,r0
|
||||||
|
cli
|
||||||
|
end;
|
||||||
|
|
||||||
|
dec(Target);
|
||||||
|
Result:=Target;
|
||||||
|
|
||||||
|
{ release interrupts }
|
||||||
|
asm
|
||||||
|
ld r0,sreg
|
||||||
|
out 0x3f,r0
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InterLockedIncrement (var Target: longint) : longint;
|
||||||
|
var
|
||||||
|
sreg : byte;
|
||||||
|
begin
|
||||||
|
{ block interrupts }
|
||||||
|
asm
|
||||||
|
in r0,0x3f
|
||||||
|
st sreg,r0
|
||||||
|
cli
|
||||||
|
end;
|
||||||
|
|
||||||
|
inc(Target);
|
||||||
|
Result:=Target;
|
||||||
|
|
||||||
|
{ release interrupts }
|
||||||
|
asm
|
||||||
|
ld r0,sreg
|
||||||
|
out 0x3f,r0
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InterLockedExchange (var Target: longint;Source : longint) : longint;
|
||||||
|
var
|
||||||
|
sreg : byte;
|
||||||
|
begin
|
||||||
|
{ block interrupts }
|
||||||
|
asm
|
||||||
|
in r0,0x3f
|
||||||
|
st sreg,r0
|
||||||
|
cli
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=Target;
|
||||||
|
Target:=Source;
|
||||||
|
|
||||||
|
{ release interrupts }
|
||||||
|
asm
|
||||||
|
ld r0,sreg
|
||||||
|
out 0x3f,r0
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint;
|
||||||
|
var
|
||||||
|
sreg : byte;
|
||||||
|
begin
|
||||||
|
{ block interrupts }
|
||||||
|
asm
|
||||||
|
in r0,0x3f
|
||||||
|
st sreg,r0
|
||||||
|
cli
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=Target;
|
||||||
|
if Target=Comperand then
|
||||||
|
Target:=NewValue;
|
||||||
|
|
||||||
|
{ release interrupts }
|
||||||
|
asm
|
||||||
|
ld r0,sreg
|
||||||
|
out 0x3f,r0
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint;
|
||||||
|
var
|
||||||
|
sreg : byte;
|
||||||
|
begin
|
||||||
|
{ block interrupts }
|
||||||
|
asm
|
||||||
|
in r0,0x3f
|
||||||
|
st sreg,r0
|
||||||
|
cli
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=Target;
|
||||||
|
inc(Target,Source);
|
||||||
|
|
||||||
|
{ release interrupts }
|
||||||
|
asm
|
||||||
|
ld r0,sreg
|
||||||
|
out 0x3f,r0
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user