qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Michael Rolnik <mrolnik@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Michael Rolnik <rolnik@amazon.com>
Subject: Re: [Qemu-devel] [PATCH 08/10] target-avr: adding instruction translation
Date: Mon, 6 Jun 2016 12:17:09 -0700	[thread overview]
Message-ID: <f7122d63-b26f-e5c6-36ab-fdff0e88783e@twiddle.net> (raw)
In-Reply-To: <CAK4993jGd3tHZZVDk2PjEOmDUxrLFvcW2LG1ccykn-z+vRSEfw@mail.gmail.com>

On 06/05/2016 11:52 PM, Michael Rolnik wrote:
> truth table shows that these computations are different.

You're not giving the right inputs to the truth table.

> you can't look onto 4th bit because 4th bits in the input were not 0s.

What did you think the xor's do?  They remove the non-zero input bits.

#include <stdio.h>

static int orig(int r, int d, int s)
{
   return (((d & s) | (d & ~r) | (s & ~r)) & 2) != 0;
}

static int mine(int r, int d, int s)
{
   return (((d ^ s) ^ r) & 4) != 0;
}

int main()
{
   int s, d;
   for (s = 0; s < 8; ++s)
     for (d = 0; d < 8; ++d)
       {
	int r = d + s;
	int o = orig(r, d, s);
         int m = mine(r, d, s);

	if (o != m)
	  printf("%2d = %d + %d  (o=%d, m=%d)\n", r, d, s, o, m);
       }
   return 0;
}

This performs tests on 3-bit inputs, testing for carry-out on bit 1, just like 
Hf computes carry-out on bit 3.


>     Then you've got the order of the stores wrong.  Your code pushes the LSB
>     before pushing the MSB, which results in the MSB at the lower address,
>     which means big-endian.
>
> this is right. However as far as I understand AVR is neither little nor big
> endian because there it's 8 bit architecture (see
> here http://www.avrfreaks.net/forum/endian-issue). for time being I defined the
> platform to be little endian with ret address exception

True, AVR is an 8-bit core, where endianness doesn't (normally) apply.  And you 
are right that ADIW does treat the registers as little-endian.

But the only multi-byte store to memory is in big-endian order.  So why 
wouldn't you want to take advantage of that fact?

>     You have swapped the overflow conditions for INC and DEC.
...
> this is how it's defined in the document.

No, it isn't.  Look again, you've swapped them.


r~

  reply	other threads:[~2016-06-06 19:17 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 20:06 [Qemu-devel] [PATCH 01/10] target-avr: AVR cores support is added. 1. basic CPU structure 2. registers 3. no instructions Michael Rolnik
2016-06-02 20:06 ` [Qemu-devel] [PATCH 02/10] target-avr: adding AVR CPU features/flavors Michael Rolnik
2016-06-04 20:02   ` Richard Henderson
2016-06-02 20:06 ` [Qemu-devel] [PATCH 03/10] target-avr: adding a sample AVR board Michael Rolnik
2016-06-02 20:06 ` [Qemu-devel] [PATCH 04/10] target-avr: adding instructions encodings Michael Rolnik
2016-06-04 22:17   ` Richard Henderson
2016-06-05  5:09     ` Michael Rolnik
2016-06-05 16:08       ` Richard Henderson
2016-06-02 20:06 ` [Qemu-devel] [PATCH 05/10] target-avr: adding AVR interrupt handling Michael Rolnik
2016-06-04 22:26   ` Richard Henderson
2016-06-05  5:10     ` Michael Rolnik
2016-06-02 20:06 ` [Qemu-devel] [PATCH 06/10] target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions Michael Rolnik
2016-06-04 22:48   ` Richard Henderson
2016-06-05  5:10     ` Michael Rolnik
2016-06-02 20:06 ` [Qemu-devel] [PATCH 07/10] target-avr: adding instruction decoder Michael Rolnik
2016-06-04 23:00   ` Richard Henderson
2016-06-05  5:18     ` Michael Rolnik
2016-06-02 20:07 ` [Qemu-devel] [PATCH 08/10] target-avr: adding instruction translation Michael Rolnik
2016-06-05  3:27   ` Richard Henderson
2016-06-05 21:47     ` Michael Rolnik
2016-06-05 23:34       ` Richard Henderson
2016-06-06  6:52         ` Michael Rolnik
2016-06-06 19:17           ` Richard Henderson [this message]
2016-06-06 19:34             ` Michael Rolnik
2016-06-02 20:07 ` [Qemu-devel] [PATCH 09/10] target-avr: updating translate.c to use instructions translation Michael Rolnik
2016-06-05  3:33   ` Richard Henderson
2016-06-05 21:49     ` Michael Rolnik
2016-06-02 20:07 ` [Qemu-devel] [PATCH 10/10] target-avr: fixing code style Michael Rolnik
2016-06-02 23:10   ` Peter Maydell
2016-06-04 17:41     ` Richard Henderson
2016-06-04 18:34       ` Michael Rolnik
2016-06-04 22:33         ` Richard Henderson
2016-06-05 12:27           ` Peter Maydell
2016-06-05  3:34   ` Richard Henderson
2016-06-04 19:55 ` [Qemu-devel] [PATCH 01/10] target-avr: AVR cores support is added. 1. basic CPU structure 2. registers 3. no instructions Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2016-06-02 20:03 Michael Rolnik
2016-06-02 20:04 ` [Qemu-devel] [PATCH 08/10] target-avr: adding instruction translation Michael Rolnik

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=f7122d63-b26f-e5c6-36ab-fdff0e88783e@twiddle.net \
    --to=rth@twiddle.net \
    --cc=mrolnik@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rolnik@amazon.com \
    /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 NNTP newsgroup(s).