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.
 
 
 
 
 

75 lignes
1.7 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. #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. char text[MAX_SYMBOL_SIZE];
  36. } ASMArgLabel;
  37. typedef struct {
  38. ASMArgType type;
  39. union {
  40. ASMArgRegister reg;
  41. ASMArgImmediate imm;
  42. ASMArgLabel label;
  43. } addr;
  44. } ASMArgIndirect;
  45. typedef struct {
  46. ASMArgRegister reg;
  47. int8_t offset;
  48. } ASMArgIndexed;
  49. typedef enum {
  50. COND_NZ, COND_N, 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. ASMArgIndirect indirect;
  58. ASMArgIndexed index;
  59. ASMArgLabel label;
  60. ASMArgCondition cond;
  61. } data;
  62. } ASMInstArg;