Przeglądaj źródła

Implement parsing .rom_size directive.

master
Ben Kurtovic 9 lat temu
rodzic
commit
2cb9b2596c
3 zmienionych plików z 21 dodań i 4 usunięć
  1. +19
    -2
      src/assembler/parse_util.c
  2. +1
    -0
      src/assembler/parse_util.h
  3. +1
    -2
      src/assembler/preprocessor.c

+ 19
- 2
src/assembler/parse_util.c Wyświetl plik

@@ -127,7 +127,24 @@ bool parse_uint8_t(uint8_t *result, const ASMLine *line, const char *directive)
}

/*
Parse the region code string in an ASMLine and store it in *result.
Parse a ROM size string in an ASMLine and store it in *result.

Return true on success and false on failure; in the latter case, *result is
not modified.
*/
bool parse_rom_size(uint32_t *result, const ASMLine *line)
{
uint32_t bytes;
if (!parse_uint32_t(&bytes, line, DIR_ROM_SIZE))
return false;

if (size_bytes_to_code(bytes))
return (*result = bytes), true;
return false;
}

/*
Parse a region code string in an ASMLine and store it in *result.

Return true on success and false on failure; in the latter case, *result is
not modified.
@@ -155,7 +172,7 @@ bool parse_region_string(uint8_t *result, const ASMLine *line)
}

/*
Parse the size code in an ASMLine and store it in *result.
Parse a size code in an ASMLine and store it in *result.

Return true on success and false on failure; in the latter case, *result is
not modified.


+ 1
- 0
src/assembler/parse_util.h Wyświetl plik

@@ -17,5 +17,6 @@ bool parse_uint32_t(uint32_t*, const ASMLine*, const char*);
bool parse_uint16_t(uint16_t*, const ASMLine*, const char*);
bool parse_uint8_t(uint8_t*, const ASMLine*, const char*);

bool parse_rom_size(uint32_t*, const ASMLine*);
bool parse_region_string(uint8_t*, const ASMLine*);
bool parse_size_code(uint8_t*, const ASMLine*);

+ 1
- 2
src/assembler/preprocessor.c Wyświetl plik

@@ -360,8 +360,7 @@ ErrorInfo* preprocess(AssemblerState *state, const LineBuffer *source)
END_DIRECTIVE

BEGIN_DIRECTIVE(DIR_ROM_SIZE, size_t, state->rom_size, 0)
// TODO: fixme
FAIL_ON_COND_(1, ED_PP_UNKNOWN)
USE_PARSER(uint32_t, rom_size)
END_DIRECTIVE

BEGIN_DIRECTIVE(DIR_ROM_HEADER, size_t, state->header.offset, DEFAULT_HEADER_OFFSET)


Ładowanie…
Anuluj
Zapisz