An emulator, assembler, and disassembler for the Sega Game Gear
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

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