makefile change

This commit is contained in:
inixyz
2023-10-29 15:37:00 +02:00
parent 78b699a86a
commit 468a4a5942
10 changed files with 23 additions and 94 deletions

View File

@@ -107,10 +107,12 @@ void regdump(const tinyriscv_core* core){
void memdump(const tinyriscv_core* core, uint32_t addr){
addr -= tinyriscv_MEM_OFFSET;
if(addr + 256 > core->mem_size) help("memdump: Address out of memory range.");
if(addr + 256 > core->mem_size){
help("memdump: Address out of memory range.");
}
printf("\n");
printf(" Address Memory ASCII\n ");
printf(" Address Memory ASCII\n");
for(unsigned int i = 0; i < 73; i++) printf("");
printf("\n");
@@ -157,7 +159,10 @@ void load_mem_from_file(tinyriscv_core* core, const char* file_path){
exit(-1);
}
fread(core->mem, 1, file_size, file);
if(fread(core->mem, 1, file_size, file) != file_size){
perror("ERROR: 'fread' count different from expected file size.");
exit(-1);
}
fclose(file);
}
@@ -177,6 +182,7 @@ int main(int argc, char** argv){
else if(!strcmp(argv[i], "--bin")){
if(i + 1 >= argc) help("Invalid file path.");
strncpy(file_path, argv[i++ + 1], 256);
file_path[255] = '\0';
}
else if(!strcmp(argv[i], "--mem_size")){
if(i + 1 >= argc) help("Invalid [mem_size] value.");

View File

@@ -164,7 +164,7 @@ void tinyriscv_step(tinyriscv_core* core){
#define rs1 (inst >> 15 & 0x1f)
#define rs2 (inst >> 20 & 0x1f)
#define imm_i ((i32)inst >> 20)
#define imm_s (imm_i & 0xffffffe0 | rd)
#define imm_s ((imm_i & 0xffffffe0) | rd)
#define imm_b (((i32)(inst & 0x80000000) >> 19) | \
((inst & 0x80) << 4) | (inst >> 20 & 0x7e0) | (inst >> 7 & 0x1e))