Tag: 符号扩展

尝试将“字节”信息存储到%x时发生位扩展

所以我目前需要读取一串hexASCII字符并使用它们来确定特定的操作码。 为此,我打开一个文本文件(它不是真的,但为了简单的解释,我们将其称之为)然后在行中读取。 所以,如果我得到一个像40f1这样的行…我让函数读取2个字符并将它们作为unsigned int存储到mem_byte中。 然后我将它转换为char用作数组并保留“byte”值的信息或两个hex数字的数值,这些数字是通过读取2个hex数字的ASCII字符表示获得的。 void getInstructions(FILE* read_file, int* stack_point, char** instructions, int size) { unsigned int mem_byte; int ins_idx = 0; char* ins_set = malloc(sizeof(char) * size); //Set size of the array of bytes for memory. Temporarily holds the memory of the program fscanf(read_file, “%d”, stack_point); //Reading in the memory from the program file […]