diff options
| author | Keith Packard <keithp@keithp.com> | 2009-04-12 21:47:32 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-04-12 21:47:32 -0700 | 
| commit | 11c526bdcbf4012e18fbfdc29ca8832870ca38f0 (patch) | |
| tree | 73445ed65dfce468b0bdf147bf2d1610e4b885be | |
| parent | 5221dc63cf3a059a32aca2bfa7828c215be814a1 (diff) | |
Add load command to s51
| -rw-r--r-- | s51/s51-command.c | 33 | 
1 files changed, 32 insertions, 1 deletions
| diff --git a/s51/s51-command.c b/s51/s51-command.c index cc208abf..02ecdddd 100644 --- a/s51/s51-command.c +++ b/s51/s51-command.c @@ -493,7 +493,38 @@ command_step (int argc, char **argv)  enum command_result  command_load (int argc, char **argv)  { -	return command_error; +	char *filename = argv[1]; +	FILE *file; +	struct hex_file	*hex; +	struct hex_image *image; +	 +	if (!filename) +		return command_error; +	file = fopen(filename, "r"); +	if (!file) { +		perror(filename); +		return command_error; +	} +	hex = ccdbg_hex_file_read(file, filename); +	fclose(file); +	if (!hex) { +		return command_error; +	} +	image = ccdbg_hex_image_create(hex); +	ccdbg_hex_file_free(hex); +	if (!image) { +		fprintf(stderr, "image create failed\n"); +		return command_error; +	} +	if (image->address >= 0xf000) { +		printf("Loading %d bytes to RAM at 0x%04x\n", +		       image->length, image->address); +		ccdbg_write_hex_image(s51_dbg, image, 0); +	} else { +		fprintf(stderr, "Can only load to RAM\n"); +	} +	ccdbg_hex_image_free(image); +	return command_success;  }  enum command_result | 
