changeset 55:f9846719aa26

Remove old 48K limit in assembler
author Michael Pavone <pavone@retrodev.com>
date Wed, 31 Aug 2016 22:41:05 -0700
parents bce01001a8c1
children fa9cf7108ab7
files src/asm.c
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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;