public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Belyashov <sergey.belyashov@gmail.com>
To: cgen@sourceware.org
Subject: Writing .cpu file for Z80
Date: Tue, 24 Mar 2020 00:44:27 +0300	[thread overview]
Message-ID: <CAOe0RDxvHb73a9cWmr4UsQUj5PpirA-ZMPm2NEuu_KLv0b4vdA@mail.gmail.com> (raw)

Hi,
I trying to write .cpu file for Z80. Now I stopped in place, how to
implement multibyte opcodes. Z80 instructions may have size from one byte
to four bytes:
<opcode> [<imm8>|<imm16>]
<0xED> <opcode> [<imm8>|<imm16>]
<0xCB> <opcode>
<0xDD/0xFD> <0xCB> <disp8> <opcode>
<0xDD/0xFD> <opcode> [<imm8>|<disp8>|<imm16>]
<0xDD/0xFD> <opcode> <disp8> <imm8>

First format is implemented, now I try second one. Starting from simple
instruction RETN (ED 45):
(dnf f-0 "whole byte 0" ((MACH z80) all-isas) 7 8)
(dnf f-1  "whole byte 1" ((MACH z80) all-isas) 15 8)
(dni retn       "return from NMI handler" (all-isas UNCOND-CTI) "retn" (+
(f-0 #xED) (f-1 #x45)) () ())

But disassembler do not disassemble 0xED 0x45 sequence. I try declare
opcode as one 16-bit field, but CGEN fails:
> Error: Instruction has opcode bits outside of its mask.
> This usually means some kind of error in the instruction's ifield list.
> base mask: 0xffff, base value: 0xed45
> field list: (f-xx 15 16)

What I'm doing wrong?

whole .cpu file is available here:
https://github.com/b-s-a/binutils-gdb/tree/z80-cgen/cpu

Best regards,
Sergey Belyashov

             reply	other threads:[~2020-03-23 21:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 21:44 Sergey Belyashov [this message]
2020-03-24 21:20 ` Sergey Belyashov
  -- strict thread matches above, loose matches on Subject: below --
2020-02-21 14:51 Sergey Belyashov
2020-02-22 15:11 ` Frank Ch. Eigler
2020-02-22 19:19   ` Sergey Belyashov
2020-02-23  0:03     ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOe0RDxvHb73a9cWmr4UsQUj5PpirA-ZMPm2NEuu_KLv0b4vdA@mail.gmail.com \
    --to=sergey.belyashov@gmail.com \
    --cc=cgen@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).