From a5d36e1bc6578d7d0ee6bab5f5defeb71a21c499 Mon Sep 17 00:00:00 2001 From: nickysn Date: Tue, 28 Apr 2020 00:05:53 +0000 Subject: [PATCH] + added Z80 helper functions is_regpair and split_regpair git-svn-id: trunk@45149 - --- compiler/z80/cpubase.pas | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/compiler/z80/cpubase.pas b/compiler/z80/cpubase.pas index 313f49fd56..9d901abe9e 100644 --- a/compiler/z80/cpubase.pas +++ b/compiler/z80/cpubase.pas @@ -277,6 +277,8 @@ unit cpubase; function findreg_by_number(r:Tregister):tregisterindex; function std_regnum_search(const s:string):Tregister; function std_regname(r:Tregister):string; + function is_regpair(r:Tregister):boolean; + procedure split_regpair(regpair:Tregister;out reglo,reghi:Tregister); function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE} function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE} @@ -397,6 +399,41 @@ unit cpubase; end; + function is_regpair(r: Tregister): boolean; + begin + result:=(r=NR_AF) or (r=NR_BC) or (r=NR_DE) or (r=NR_HL); + end; + + + procedure split_regpair(regpair: Tregister; out reglo, reghi: Tregister); + begin + case regpair of + NR_AF: + begin + reglo:=NR_F; + reghi:=NR_A; + end; + NR_BC: + begin + reglo:=NR_C; + reghi:=NR_B; + end; + NR_DE: + begin + reglo:=NR_E; + reghi:=NR_D; + end; + NR_HL: + begin + reglo:=NR_L; + reghi:=NR_H; + end; + else + internalerror(2020042801); + end; + end; + + function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE} const inverse: array[TAsmCond] of TAsmCond=(C_None,