37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/**
|
|
* ZRE - A lightweight, portable programming language for permacomputing.
|
|
* Copyright (C) 2025 zongor
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "debug.h"
|
|
|
|
int core_dump(Word *memory, uint32_t memory_size) {
|
|
FILE *file = fopen("memory_dump.bin", "wb");
|
|
if (!file) {
|
|
perror("Failed to open file");
|
|
return EXIT_FAILURE;
|
|
}
|
|
size_t written = fwrite(memory, 1, memory_size, file);
|
|
if (written != memory_size) {
|
|
fprintf(stderr, "Incomplete write: %zu bytes written out of %u\n", written,
|
|
memory_size);
|
|
fclose(file);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
fclose(file);
|
|
return EXIT_SUCCESS;
|
|
}
|