An emulator, assembler, and disassembler for the Sega Game Gear
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

50 lignes
2.8 KiB

  1. /* Copyright (C) 2014-2016 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #include "mnemonics.h"
  4. static char* instr_mnemonics[256] = {
  5. /* 00 */ "nop", "ld", "ld", "inc", "inc", "dec", "ld", "rlca",
  6. /* 08 */ "ex", "add", "ld", "dec", "inc", "dec", "ld", "rrca",
  7. /* 10 */ "djnz", "ld", "ld", "inc", "inc", "dec", "ld", "rla",
  8. /* 18 */ "jr", "add", "ld", "dec", "inc", "dec", "ld", "rra",
  9. /* 20 */ "jr", "ld", "ld", "inc", "inc", "dec", "ld", "daa",
  10. /* 28 */ "jr", "add", "ld", "dec", "inc", "dec", "ld", "cpl",
  11. /* 30 */ "jr", "ld", "ld", "inc", "inc", "dec", "ld", "scf",
  12. /* 38 */ "jr", "add", "ld", "dec", "inc", "dec", "ld", "ccf",
  13. /* 40 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  14. /* 48 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  15. /* 50 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  16. /* 58 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  17. /* 60 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  18. /* 68 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  19. /* 70 */ "ld", "ld", "ld", "ld", "ld", "ld", "halt", "ld",
  20. /* 78 */ "ld", "ld", "ld", "ld", "ld", "ld", "ld", "ld",
  21. /* 80 */ "add", "add", "add", "add", "add", "add", "add", "add",
  22. /* 88 */ "adc", "adc", "adc", "adc", "adc", "adc", "adc", "adc",
  23. /* 90 */ "sub", "sub", "sub", "sub", "sub", "sub", "sub", "sub",
  24. /* 98 */ "sbc", "sbc", "sbc", "sbc", "sbc", "sbc", "sbc", "sbc",
  25. /* A0 */ "and", "and", "and", "and", "and", "and", "and", "and",
  26. /* A8 */ "xor", "xor", "xor", "xor", "xor", "xor", "xor", "xor",
  27. /* B0 */ "or", "or", "or", "or", "or", "or", "or", "or",
  28. /* B8 */ "cp", "cp", "cp", "cp", "cp", "cp", "cp", "cp",
  29. /* C0 */ "ret", "pop", "jp", "jp", "call", "push", "add", "rst",
  30. /* C8 */ "ret", "ret", "jp", "", "call", "call", "adc", "rst",
  31. /* D0 */ "ret", "pop", "jp", "out", "call", "push", "sub", "rst",
  32. /* D8 */ "ret", "exx", "jp", "in", "call", "", "sbc", "rst",
  33. /* E0 */ "ret", "pop", "jp", "ex", "call", "push", "and", "rst",
  34. /* E8 */ "ret", "jp", "jp", "ex", "call", "", "xor", "rst",
  35. /* F0 */ "ret", "pop", "jp", "di", "call", "push", "or", "rst",
  36. /* F8 */ "ret", "ld", "jp", "ei", "call", "", "cp", "rst"
  37. };
  38. /*
  39. Extract the assembly mnemonic for the given opcode.
  40. The return value is a string literal and should not be freed.
  41. */
  42. char* decode_mnemonic(const uint8_t *bytes)
  43. {
  44. return instr_mnemonics[bytes[0]]; // TODO: extended...
  45. }