소스 검색

Implement parsing .rom_size directive.

master
Ben Kurtovic 9 년 전
부모
커밋
2cb9b2596c
3개의 변경된 파일21개의 추가작업 그리고 4개의 파일을 삭제
  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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

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


불러오는 중...
취소
저장