/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8                                :viâ
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¡
â Copyright 2020 Justine Alexandra Roberts Tunney                              â
â                                                                              â
â Permission to use, copy, modify, and/or distribute this software for         â
â any purpose with or without fee is hereby granted, provided that the         â
â above copyright notice and this permission notice appear in all copies.      â
â                                                                              â
â THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL                â
â WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED                â
â WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE             â
â AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL         â
â DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR        â
â PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER               â
â TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             â
â PERFORMANCE OF THIS SOFTWARE.                                                â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
#include "libc/testlib/testlib.h"
#include "test/libc/xed/lib.h"
#include "third_party/xed/x86.h"

/**
 * @fileoverview Hefty NOPs.
 */

TEST(x86ild, test_nop9_660F1F840000000000) {
  /*
    ICLASS: NOP
    CATEGORY: WIDENOP
    EXTENSION: BASE
    IFORM: NOP_MEMv_GPRv_0F1F
    ISA_SET: FAT_NOP
    SHORT: nop word ptr [rax+rax*1], ax
  */
  ASSERT_EQ(9, ild(u"fâ¼â¼Ã¤Â Â Â Â Â "));
}

TEST(x86ild, test_nop8_0F1F840000000000) {
  /* nopl 0x00000000(%rax,%rax,1) */
  ASSERT_EQ(8, ild(u"â¼â¼Ã¤Â Â Â Â Â "));
}

TEST(x86ild, test_nop7_0F1F8000000000) {
  /* nopl 0x00000000(%rax) */
  ASSERT_EQ(7, ild(u"â¼â¼ÃÂ Â Â Â "));
}

TEST(x86ild, test_nop6_660F1F440000) {
  /*
    ICLASS: NOP
    CATEGORY: WIDENOP
    EXTENSION: BASE
    IFORM: NOP_MEMv_GPRv_0F1F
    ISA_SET: FAT_NOP
    SHORT: nop word ptr [rax+rax*1], ax
  */
  ASSERT_EQ(6, ild(u"fâ¼â¼DÂ Â "));
}

TEST(x86ild, test_nop5_0F1F440000) {
  /*
    ICLASS: NOP
    CATEGORY: WIDENOP
    EXTENSION: BASE
    IFORM: NOP_MEMv_GPRv_0F1F
    ISA_SET: FAT_NOP
    SHORT: nop dword ptr [rax+rax*1], eax
  */
  ASSERT_EQ(5, ild(u"â¼â¼DÂ Â "));
}

TEST(x86ild, test_nop4_0F1F4000) {
  /*
    ICLASS: NOP
    CATEGORY: WIDENOP
    EXTENSION: BASE
    IFORM: NOP_MEMv_GPRv_0F1F
    ISA_SET: FAT_NOP
    SHORT: nop dword ptr [rax], eax
  */
  ASSERT_EQ(4, ild(u"â¼â¼@Â "));
}

TEST(x86ild, test_nop3_0F1F00) {
  /*
    ICLASS: NOP
    CATEGORY: WIDENOP
    EXTENSION: BASE
    IFORM: NOP_MEMv_GPRv_0F1F
    ISA_SET: FAT_NOP
    SHORT: nop dword ptr [rax], eax
  */
  ASSERT_EQ(3, ild(u"â¼â¼Â "));
}

TEST(x86ild, test_nop2_6690) {
  /* xchg %ax,%ax */
  ASSERT_EQ(2, ild(u"fÃ"));
}

TEST(x86ild, test_nop1_90) {
  /* xchg %eax,%eax */
  ASSERT_EQ(1, ild(u"Ã"));
}
