An emulator, assembler, and disassembler for the Sega Game Gear
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

inst_args.h 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_REGISTER,
  8. AT_IMMEDIATE,
  9. AT_INDIRECT,
  10. AT_INDEXED,
  11. AT_LABEL,
  12. AT_CONDITION
  13. } ASMArgType;
  14. typedef enum {
  15. REG_A, REG_F, REG_B, REG_C, REG_D, REG_E, REG_H, REG_L, REG_I, REG_R,
  16. REG_AF, REG_BC, REG_DE, REG_HL, REG_IX, REG_IY,
  17. REG_PC, REG_SP,
  18. REG_AF_, REG_IXH, REG_IXL, REG_IYH, REG_IYL
  19. } ASMArgRegister;
  20. typedef enum {
  21. IMM_U16 = 0x01, // unsigned 16-bit: [0, 65535]
  22. IMM_U8 = 0x02, // unsigned 8-bit: [0, 255]
  23. IMM_S8 = 0x04, // signed 8-bit: [-128, 127]
  24. IMM_REL = 0x08, // relative offset: [-126, 129]
  25. IMM_BIT = 0x10, // bit index: [0, 7]
  26. IMM_RST = 0x20, // RST page 0 addr: {0x00, 0x08, 0x10, 0x18, ..., 0x38}
  27. IMM_IM = 0x40 // interrupt mode: [0, 2]
  28. } ASMArgImmType;
  29. typedef struct {
  30. ASMArgImmType mask;
  31. uint16_t uval;
  32. int16_t sval;
  33. } ASMArgImmediate;
  34. typedef struct {
  35. ASMArgType type;
  36. union {
  37. ASMArgRegister reg;
  38. ASMArgImmediate imm;
  39. } addr;
  40. } ASMArgIndirect;
  41. typedef struct {
  42. ASMArgRegister reg;
  43. int8_t offset;
  44. } ASMArgIndexed;
  45. typedef struct {
  46. char text[MAX_SYMBOL_SIZE];
  47. } ASMArgLabel;
  48. typedef enum {
  49. COND_NZ, COND_N, COND_NC, COND_C, COND_PO, COND_PE, COND_P, COND_M
  50. } ASMArgCondition;
  51. typedef struct {
  52. ASMArgType type;
  53. union {
  54. ASMArgRegister reg;
  55. ASMArgImmediate imm;
  56. ASMArgIndirect indirect;
  57. ASMArgIndexed index;
  58. ASMArgLabel label;
  59. ASMArgCondition cond;
  60. } data;
  61. } ASMInstArg;