diff --git a/.gitattributes b/.gitattributes index 7b3dd1d7e7..66888a6c01 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15011,6 +15011,8 @@ tests/test/tdefault8.pp svneol=native#text/pascal tests/test/tdefault9.pp svneol=native#text/pascal tests/test/tdel1.pp svneol=native#text/plain tests/test/tdel2.pp svneol=native#text/plain +tests/test/tdes1.pp svneol=native#text/pascal +tests/test/tdes2.pp svneol=native#text/pascal tests/test/tdispinterface1a.pp svneol=native#text/pascal tests/test/tdispinterface1b.pp svneol=native#text/pascal tests/test/tdispinterface2.pp svneol=native#text/plain diff --git a/compiler/avr/ccpuinnr.inc b/compiler/avr/ccpuinnr.inc index 247084ef28..5358cd0576 100644 --- a/compiler/avr/ccpuinnr.inc +++ b/compiler/avr/ccpuinnr.inc @@ -18,5 +18,6 @@ in_avr_sleep = in_cpu_first+3, in_avr_nop = in_cpu_first+4, in_avr_save = in_cpu_first+5, - in_avr_restore = in_cpu_first+6 + in_avr_restore = in_cpu_first+6, + in_avr_des = in_cpu_first+7 diff --git a/compiler/avr/cpubase.pas b/compiler/avr/cpubase.pas index 83b5145c49..bc7837b692 100644 --- a/compiler/avr/cpubase.pas +++ b/compiler/avr/cpubase.pas @@ -53,7 +53,8 @@ unit cpubase; A_LSL,A_LSR,A_ROL,A_ROR,A_ASR,A_SWAP,A_BSET,A_BCLR,A_SBI,A_CBI, A_SEC,A_SEH,A_SEI,A_SEN,A_SER,A_SES,A_SET,A_SEV,A_SEZ, A_CLC,A_CLH,A_CLI,A_CLN,A_CLR,A_CLS,A_CLT,A_CLV,A_CLZ, - A_BST,A_BLD,A_BREAK,A_NOP,A_SLEEP,A_WDR,A_XCH); + A_BST,A_BLD,A_BREAK,A_NOP,A_SLEEP,A_WDR,A_XCH, + A_DES); { This should define the array of instructions as string } diff --git a/compiler/avr/itcpugas.pas b/compiler/avr/itcpugas.pas index ef51561206..71b77767b3 100644 --- a/compiler/avr/itcpugas.pas +++ b/compiler/avr/itcpugas.pas @@ -44,7 +44,8 @@ interface 'lsl','lsr','rol','ror','asr','swap','bset','bclr','sbi','cbi', 'sec','seh','sei','sen','ser','ses','set','sev','sez', 'clc','clh','cli','cln','clr','cls','clt','clv','clz', - 'bst','bld','break','nop','sleep','wdr','xch'); + 'bst','bld','break','nop','sleep','wdr','xch', + 'des'); function gas_regnum_search(const s:string):Tregister; function gas_regname(r:Tregister):string; diff --git a/compiler/avr/navrinl.pas b/compiler/avr/navrinl.pas index 0158a5b8a5..17137a773f 100644 --- a/compiler/avr/navrinl.pas +++ b/compiler/avr/navrinl.pas @@ -40,6 +40,8 @@ unit navrinl; implementation uses + verbose, + constexp, compinnr, aasmdata, aasmcpu, @@ -48,6 +50,7 @@ unit navrinl; hlcgobj, pass_2, cgbase, cgobj, cgutils, + ncon,ncal, cpubase; procedure tavrinlinenode.second_abs_long; @@ -94,6 +97,18 @@ unit navrinl; CheckParameters(1); resultdef:=voidtype; end; + in_avr_des: + begin + CheckParameters(2); + resultdef:=voidtype; + if not(is_constintnode(tcallparanode(left).paravalue)) then + MessagePos(tcallparanode(left).paravalue.fileinfo,type_e_constant_expr_expected); + if not(is_constboolnode(tcallparanode(tcallparanode(left).nextpara).paravalue)) then + MessagePos(tcallparanode(tcallparanode(left).nextpara).paravalue.fileinfo,type_e_constant_expr_expected); + if (tordconstnode(tcallparanode(left).paravalue).value<0) or + (tordconstnode(tcallparanode(left).paravalue).value>15) then + MessagePos(tcallparanode(left).paravalue.fileinfo,parser_e_range_check_error); + end; else Result:=inherited pass_typecheck_cpu; end; @@ -109,7 +124,8 @@ unit navrinl; in_avr_sei, in_avr_wdr, in_avr_cli, - in_avr_restore: + in_avr_restore, + in_avr_des: begin expectloc:=LOC_VOID; resultdef:=voidtype; @@ -152,6 +168,14 @@ unit navrinl; hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false); current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_OUT, NIO_SREG, left.location.register)); end; + in_avr_des: + begin + if tordconstnode(tcallparanode(tcallparanode(left).nextpara).paravalue).value=0 then + current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLH)) + else + current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SEH)); + current_asmdata.CurrAsmList.concat(taicpu.op_const(A_DES,int64(tordconstnode(tcallparanode(left).paravalue).value))); + end; else inherited pass_generate_code_cpu; end; diff --git a/compiler/avr/raavr.pas b/compiler/avr/raavr.pas index ddefb171eb..16b3d994b2 100644 --- a/compiler/avr/raavr.pas +++ b/compiler/avr/raavr.pas @@ -256,7 +256,9 @@ unit raavr; // A_WDR (numOperands: (1 shl 0); Operands: ((typ: top_none), (typ: top_none))), // A_XCH - (numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_Z), (typ: top_reg; rt: rt_all))) + (numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_Z), (typ: top_reg; rt: rt_all))), + // A_DES + (numOperands: (1 shl 1); Operands: ((typ: top_const; max: 15; min: 0), (typ: top_none))) ); {$POP} diff --git a/rtl/avr/cpuinnr.inc b/rtl/avr/cpuinnr.inc index 3ffcb009cb..1765f2969e 100644 --- a/rtl/avr/cpuinnr.inc +++ b/rtl/avr/cpuinnr.inc @@ -19,3 +19,4 @@ in_avr_nop = fpc_in_cpu_first+4; in_avr_save = fpc_in_cpu_first+5; in_avr_restore = fpc_in_cpu_first+6; + in_avr_des = fpc_in_cpu_first+7; diff --git a/rtl/avr/intrinsics.pp b/rtl/avr/intrinsics.pp index c640acb318..d6b66389c3 100644 --- a/rtl/avr/intrinsics.pp +++ b/rtl/avr/intrinsics.pp @@ -29,6 +29,8 @@ unit intrinsics; { Restores SREG } procedure avr_restore(old_sreg: byte); [INTERNPROC: in_avr_restore]; + procedure avr_des(decrypt: boolean;round: byte);[INTERNPROC: in_avr_des]; + implementation end. diff --git a/tests/test/tdes1.pp b/tests/test/tdes1.pp new file mode 100644 index 0000000000..58ed48502f --- /dev/null +++ b/tests/test/tdes1.pp @@ -0,0 +1,9 @@ +{ %cpu=avr } +{ %norun } +uses + intrinsics; +begin + avr_des(true,1); +end. + + \ No newline at end of file diff --git a/tests/test/tdes2.pp b/tests/test/tdes2.pp new file mode 100644 index 0000000000..9e5499579f --- /dev/null +++ b/tests/test/tdes2.pp @@ -0,0 +1,10 @@ +{ %fail } +{ %cpu=avr } +{ %norun } +uses + intrinsics; +begin + avr_des(true,100); +end. + + \ No newline at end of file