# HG changeset patch # User Michael Pavone # Date 1472708465 25200 # Node ID f9846719aa2643629051b6714bfb6e5d5f12c3f7 # Parent bce01001a8c1d7b5a69da1180cad28b0be172e46 Remove old 48K limit in assembler diff -r bce01001a8c1 -r f9846719aa26 src/asm.c --- a/src/asm.c Wed Aug 31 22:40:17 2016 -0700 +++ b/src/asm.c Wed Aug 31 22:41:05 2016 -0700 @@ -46,6 +46,8 @@ uint8_t expected_args; } inst_info; +#define MAX_SIZE (4*1024*1024) + label *add_label(label_meta *labels, char *name, uint16_t address, uint8_t valid) { if (labels->num_labels == labels->label_storage) { @@ -192,7 +194,7 @@ free(meta->labels); } -int handle_dc(char size, char *linebuf, uint8_t *outbuf, uint16_t *pc, label_meta *meta) +int handle_dc(char size, char *linebuf, uint8_t *outbuf, uint32_t *pc, label_meta *meta) { char *arg; long value; @@ -261,7 +263,7 @@ if (value < -128 || value > 255) { fprintf(stderr, "WARNING: %s is too large to fit in a byte\n", arg); } - if (*pc >= 48 * 1024) { + if (*pc >= MAX_SIZE) { fputs("ERROR: Hit end of ROM space\n", stderr); free(orig); return 0; @@ -272,7 +274,7 @@ if (value < -32768 || value > 65535) { fprintf(stderr, "WARNING: %s is too large to fit in a word\n", arg); } - if (*pc >= 48 * 1024 - 1) { + if (*pc >= MAX_SIZE - 1) { fputs("ERROR: Hit end of ROM space\n", stderr); free(orig); return 0; @@ -281,7 +283,7 @@ outbuf[(*pc)++] = value; break; case 'l': - if (*pc >= 48 * 1024 - 3) { + if (*pc >= MAX_SIZE - 3) { fputs("ERROR: Hit end of ROM space\n", stderr); free(orig); return 0; @@ -297,7 +299,7 @@ return 1; } -int process_arg(uint16_t *inst, char *arg, int arg_shift, int immed_min, int immed_max, label_meta *meta, uint16_t pc) +int process_arg(uint16_t *inst, char *arg, int arg_shift, int immed_min, int immed_max, label_meta *meta, uint32_t pc) { long value; if (arg[0] == 'r' && arg[1] >= '0' && arg[1] <= '9' && (arg[2] == 0 || arg[3] == 0)) { @@ -403,7 +405,7 @@ return 1; } -uint8_t handle_incbin(char *cur, uint8_t *outbuf, uint16_t *pc) +uint8_t handle_incbin(char *cur, uint8_t *outbuf, uint32_t *pc) { char * end = strchr(cur, ';'); if (end) { @@ -421,7 +423,7 @@ fprintf(stderr, "Failed to open inclued file %s for reading\n", cur); return 0; } - size_t read = fread(outbuf + *pc, 1, 48*1024-*pc, incfile); + size_t read = fread(outbuf + *pc, 1, MAX_SIZE-*pc, incfile); fclose(incfile); *pc += read; return 1; @@ -432,9 +434,8 @@ //fixed size buffers are lame, but so are lines longer than 4K characters //this is good enough for the really simple first version char linebuf[4096]; - //maximum program size is 48KB - uint8_t outbuf[48*1024]; - uint16_t pc = 0; + uint8_t outbuf[MAX_SIZE]; + uint32_t pc = 0; size_t num_labels = 0; size_t label_storage = 1024;