This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: call insn in z80


On Thu, 15 Mar 2001, brahmaiah vallabhaneni wrote:
>Hi all,
> I am working for z80 port. I have the following
>problem with the call insn pattern.
[snip]
>
>  the code looks like
>     
>    ld  bc,_first_fun
>    ld  (_p),bc
>    ld  bc,(_p)
>    ld  iy, bc
>    call (iy)   // problem.
> but actually z80 does not have an instruction 
>    call  throgh a indirect register address.

The Z80 can jump via hl, ix and iy.
Just add

__call_indirect_hl:
	jp (hl)
__call_indirect_ix:
	jp (iy)
__call_indirect_iy:
	jp (iy)

to libgcc and emit the following code

    ld  bc,_first_fun
    ld  (_p),bc
    ld  hl,(_p)
    call __call_indirect_hl

The call will place the correct return address and
the jp (hl) will set the pc 

Hartmut


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]