Browse Source

Implement parsing .rom_size directive.

master
Ben Kurtovic 9 years ago
parent
commit
2cb9b2596c
3 changed files with 21 additions and 4 deletions
  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 View File

@@ -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 View File

@@ -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 View File

@@ -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)


Loading…
Cancel
Save