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.
 
 
 
 
 

70 lignes
1.6 KiB

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