From fe5daf3d2fefc85e239fec800d5a7b9bde0bb735 Mon Sep 17 00:00:00 2001 From: nickysn Date: Wed, 1 Apr 2020 22:08:22 +0000 Subject: [PATCH] + initial implementation of top_ref reference output for sdcc-sdasz80 git-svn-id: branches/z80@44497 - --- compiler/z80/agsdasz80.pas | 66 ++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/compiler/z80/agsdasz80.pas b/compiler/z80/agsdasz80.pas index 235a0498f4..0b47dc136a 100644 --- a/compiler/z80/agsdasz80.pas +++ b/compiler/z80/agsdasz80.pas @@ -307,20 +307,60 @@ unit agsdasz80; procedure TSdccSdasZ80Assembler.WriteOper(const o: toper; s: topsize; opcode: tasmop; ops: longint; dest: boolean); - begin - case o.typ of - top_reg : - writer.AsmWrite(std_regname(o.reg)); - top_const : - begin -{ if (ops=1) and (opcode<>A_RET) then - writer.AsmWrite(sizestr(s,dest));} - writer.AsmWrite('#'+tostr(longint(o.val))); - end; - else - internalerror(10001); + var + need_plus: Boolean; + begin + case o.typ of + top_reg : + writer.AsmWrite(std_regname(o.reg)); + top_const : + begin +{ if (ops=1) and (opcode<>A_RET) then + writer.AsmWrite(sizestr(s,dest));} + writer.AsmWrite('#'+tostr(longint(o.val))); + end; + top_ref: + begin + writer.AsmWrite('('); + need_plus:=false; + if o.ref^.base<>NR_NO then + begin + if o.ref^.index<>NR_NO then + internalerror(2020040201); + writer.AsmWrite(std_regname(o.ref^.base)); + need_plus:=true; + end + else if o.ref^.index<>NR_NO then + begin + if o.ref^.scalefactor>1 then + internalerror(2020040202); + writer.AsmWrite(std_regname(o.ref^.index)); + need_plus:=true; + end; + if assigned(o.ref^.symbol) then + begin + {if SmartAsm then + AddSymbol(o.ref^.symbol.name,false);} + if need_plus then + writer.AsmWrite('+'); + writer.AsmWrite(o.ref^.symbol.name); + need_plus:=true; + end; + if o.ref^.offset>0 then + begin + if need_plus then + writer.AsmWrite('+'); + writer.AsmWrite(tostr(o.ref^.offset)); + need_plus:=true; + end; + if not need_plus then + writer.AsmWrite('0'); + writer.AsmWrite(')'); + end; + else + internalerror(10001); + end; end; - end; procedure TSdccSdasZ80Assembler.WriteTree(p: TAsmList);