0 Members and 2 Guests are viewing this topic.
char * memory = new char[0xFFFF];int readmemory_long(int pointer){ unsigned int r_pointer = pointer - 0xA4000000; //converts given pointer to the array address if (r_pointer > 0x1FFFFF) return 0; return ntohl(memory[r_pointer]); //ntohl(), converts data to little endian (I hope :P) issue here // I want to get the 32 bit value at this address}void writememory_long(int pointer, int data){ unsigned int r_pointer = pointer - 0xA4000000; if (r_pointer > 0x1FFFFF) return; memory[r_pointer] = htonl(data); //converts data to big endian: same issue}
char * memory = new char[0xFFFF];int readmemory_long(int pointer){ unsigned int r_pointer = pointer - 0xA4000000; if (r_pointer > 0x1FFFFF) return 0; int temp = int(memory[r_pointer]) * 0x1000000; temp |= int(memory[r_pointer + 1]) * 0x10000; temp |= int(memory[r_pointer + 2]) * 0x100; temp |= int(memory[r_pointer + 3]); return ntohl(temp);}short readmemory_word(int pointer){ unsigned int r_pointer = pointer - 0xA4000000; if (r_pointer > 0x1FFFFF) return 0; short temp = short(memory[r_pointer]) * 0x100; temp |= short(memory[r_pointer + 1]); return ntohs(temp);}
70 01 71 01 8B FD FF FE
PC = 0xA4000000; ifstream program("spectrum.data", ios::in|ios::binary); if(!program.is_open()) { cout << "Error opening spectrum.data"; cin.get(); return -1; } program.seekg(0, ios::beg); int program_counter; char buffer; program.read(&buffer, 1); int prog_index; while(program.good()) { writememory_byte(prog_index + 0xA4000000, buffer); prog_index++; program.seekg(prog_index); program.read(&buffer, 1); }
int temp = int(memory[r_pointer]) * 0x1000000; temp |= int(memory[r_pointer + 1]) * 0x10000; temp |= int(memory[r_pointer + 2]) * 0x100; temp |= int(memory[r_pointer + 3]); return ntohl(temp);
program >> hex; int buffer; program >> buffer; int prog_index = 0; while(program.good()) { writememory_byte(prog_index + 0xA4000000, buffer); prog_index++; program >> buffer; }
Goplat, if it's parsing "70" to the ASCII codes 0x37 and 0x30, then "01" would read 0x3031, not 0x3001. 0x01 is a non-printable ASCII control character.
if (ADD_v == instruction & ADD_v) ADD(); else if (MOVi_v == instruction & MOVi_v) MOVi(); else if (ADDi_v == instruction & ADDi_v) ADDi(); else if (MOVLi_v == instruction & MOVLi_v) MOVLi();