An emulator, assembler, and disassembler for the Sega Game Gear
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <stdint.h>
  5. #define MAX_SYMBOL_SIZE 256
  6. typedef enum {
  7. AT_NONE = 0x00,
  8. AT_OPTIONAL = 0x01,
  9. AT_REGISTER = 0x02,
  10. AT_IMMEDIATE = 0x04,
  11. AT_INDIRECT = 0x08,
  12. AT_INDEXED = 0x10,
  13. AT_CONDITION = 0x20,
  14. AT_PORT = 0x40
  15. } ASMArgType;
  16. typedef enum {
  17. REG_A, REG_F, REG_B, REG_C, REG_D, REG_E, REG_H, REG_L, REG_I, REG_R,
  18. REG_AF, REG_BC, REG_DE, REG_HL, REG_IX, REG_IY,
  19. REG_PC, REG_SP,
  20. REG_AF_, REG_IXH, REG_IXL, REG_IYH, REG_IYL
  21. } ASMArgRegister;
  22. typedef enum {
  23. IMM_U16 = 0x01, // unsigned 16-bit: [0, 65535]
  24. IMM_U8 = 0x02, // unsigned 8-bit: [0, 255]
  25. IMM_S8 = 0x04, // signed 8-bit: [-128, 127]
  26. IMM_REL = 0x08, // relative offset: [-126, 129]
  27. IMM_BIT = 0x10, // bit index: [0, 7]
  28. IMM_RST = 0x20, // RST page 0 addr: {0x00, 0x08, 0x10, 0x18, ..., 0x38}
  29. IMM_IM = 0x40 // interrupt mode: [0, 2]
  30. } ASMArgImmType;
  31. typedef struct {
  32. ASMArgImmType mask;
  33. bool is_label;
  34. uint16_t uval;
  35. int16_t sval;
  36. char label[MAX_SYMBOL_SIZE];
  37. } ASMArgImmediate;
  38. typedef struct {
  39. ASMArgType type;
  40. union {
  41. ASMArgRegister reg;
  42. ASMArgImmediate imm;
  43. } addr;
  44. } ASMArgIndirect;
  45. typedef struct {
  46. ASMArgRegister reg;
  47. int8_t offset;
  48. } ASMArgIndexed;
  49. typedef enum {
  50. COND_NZ, COND_Z, COND_NC, COND_C, COND_PO, COND_PE, COND_P, COND_M
  51. } ASMArgCondition;
  52. typedef struct {
  53. ASMArgType type;
  54. union {
  55. ASMArgRegister reg;
  56. ASMArgImmediate imm;
  57. } port;
  58. } ASMArgPort;
  59. typedef struct {
  60. ASMArgType type;
  61. union {
  62. ASMArgRegister reg;
  63. ASMArgImmediate imm;
  64. ASMArgIndirect indirect;
  65. ASMArgIndexed index;
  66. ASMArgCondition cond;
  67. ASMArgPort port;
  68. } data;
  69. } ASMInstArg;