An emulator, assembler, and disassembler for the Sega Game Gear
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.8 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 <string.h>
  5. #define DIRECTIVE_MARKER '.'
  6. #define NUM_DIRECTIVES 15
  7. #define DIR_INCLUDE ".include"
  8. #define DIR_ROM_SIZE ".rom_size"
  9. #define DIR_ROM_HEADER ".rom_header"
  10. #define DIR_ROM_CHECKSUM ".rom_checksum"
  11. #define DIR_ROM_PRODUCT ".rom_product"
  12. #define DIR_ROM_VERSION ".rom_version"
  13. #define DIR_ROM_REGION ".rom_region"
  14. #define DIR_ROM_DECLSIZE ".rom_declsize"
  15. #define DIR_CROSS_BLOCKS ".cross_blocks"
  16. #define DIR_ORIGIN ".org"
  17. #define DIR_BLOCK ".block"
  18. #define DIR_BYTE ".byte"
  19. #define DIR_ASCII ".ascii"
  20. #define DIR_ASCIZ ".asciz"
  21. #define DIR_ASCIIZ ".asciiz"
  22. #define DIRECTIVE_HAS_ARG(line, d) ((line)->length > strlen(d))
  23. #define IS_DIRECTIVE(line, d) \
  24. (((line)->length >= strlen(d)) && \
  25. !strncmp((line)->data, d, strlen(d)) && \
  26. (!DIRECTIVE_HAS_ARG(line, d) || (line)->data[strlen(d)] == ' '))
  27. #define IS_LOCAL_DIRECTIVE(line) \
  28. (IS_DIRECTIVE(line, DIR_ORIGIN) || IS_DIRECTIVE(line, DIR_BLOCK) || \
  29. IS_DIRECTIVE(line, DIR_BYTE) || IS_DIRECTIVE(line, DIR_ASCII) || \
  30. IS_DIRECTIVE(line, DIR_ASCIZ) || IS_DIRECTIVE(line, DIR_ASCIIZ))
  31. #define DIRECTIVE_OFFSET(line, d) \
  32. (DIRECTIVE_HAS_ARG(line, d) ? strlen(d) : 0)
  33. #define DIRECTIVE_IS_AUTO(line, d) \
  34. (line->length - (DIRECTIVE_OFFSET(line, d) + 1) == 4 && \
  35. !strncmp(line->data + (DIRECTIVE_OFFSET(line, d) + 1), "auto", 4))