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.
 
 
 
 
 

82 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 <stdbool.h>
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. #include "../assembler.h"
  8. #define DEFAULT_HEADER_OFFSET 0x7FF0
  9. #define DEFAULT_REGION 6 // GG Export
  10. #define SYMBOL_TABLE_BUCKETS 128
  11. /* Structs */
  12. struct ASMLine {
  13. char *data;
  14. size_t length;
  15. const Line *original;
  16. const char *filename;
  17. struct ASMLine *next;
  18. };
  19. typedef struct ASMLine ASMLine;
  20. struct ASMInclude {
  21. LineBuffer *lines;
  22. struct ASMInclude *next;
  23. };
  24. typedef struct ASMInclude ASMInclude;
  25. struct ASMInstruction {
  26. size_t offset;
  27. uint8_t length;
  28. uint8_t b1, b2, b3, b4;
  29. uint8_t virtual_byte;
  30. char *symbol;
  31. struct ASMInstruction *next;
  32. };
  33. typedef struct ASMInstruction ASMInstruction;
  34. struct ASMSymbol {
  35. size_t offset;
  36. char *symbol;
  37. struct ASMSymbol *next;
  38. };
  39. typedef struct ASMSymbol ASMSymbol;
  40. typedef struct {
  41. ASMSymbol *buckets[SYMBOL_TABLE_BUCKETS];
  42. } ASMSymbolTable;
  43. typedef struct {
  44. size_t offset;
  45. bool checksum;
  46. uint32_t product_code;
  47. uint8_t version;
  48. uint8_t region;
  49. uint8_t rom_size;
  50. } ASMHeaderInfo;
  51. typedef struct {
  52. ASMHeaderInfo header;
  53. bool optimizer;
  54. size_t rom_size;
  55. ASMLine *lines;
  56. ASMInclude *includes;
  57. ASMInstruction *instructions;
  58. ASMSymbolTable *symtable;
  59. } AssemblerState;
  60. /* Functions */
  61. void state_init(AssemblerState*);
  62. void asm_symtable_init(ASMSymbolTable**);
  63. void asm_lines_free(ASMLine*);
  64. void asm_includes_free(ASMInclude*);
  65. void asm_instructions_free(ASMInstruction*);
  66. void asm_symtable_free(ASMSymbolTable*);