Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sv command does not work #5

Open
slugrustle opened this issue Aug 9, 2021 · 0 comments
Open

sv command does not work #5

slugrustle opened this issue Aug 9, 2021 · 0 comments

Comments

@slugrustle
Copy link

slugrustle commented Aug 9, 2021

The sv command, even the one copied from the readme, does not appear to function. The following occurs on my system:

Enter a command: sv 100000011000000000000000000000000000
16: 111111111111111111111111111111111111spot▒╩Üc▄ε

The below modification to the code appears to fix things:

    else if(memcmp(buff,"sv",2) == 0)
    { 
		char instruction_string[WORD_SIZE];
		memset(instruction_string, 0, WORD_SIZE);
		if (read_size > 3)
		        memcpy(instruction_string, buff+3, WORD_SIZE < read_size-3 ? WORD_SIZE : read_size-3);
	  
		int *byte_value;
		byte_value = (int*) malloc(WORD_SIZE*sizeof(int));
		byte_value_from_string(instruction_string,byte_value,WORD_SIZE);
		for(int i=0; i<WORD_SIZE; i++)
			Machine_Memory[pc.current_address][i] = byte_value[i];

		set_address(&pc,pc.current_address,Machine_Memory);
		free(byte_value);
		char* memory_value = (char*) malloc(WORD_SIZE);
		byte_value_to_string(Machine_Memory[pc.current_address], memory_value, WORD_SIZE);
		fprintf(stdout, "%d: %s\n",pc.current_address, memory_value);
		free(memory_value);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant