Compare commits
No commits in common. "7ae98d8353550ac79a0048a74ca11a6869497b8b" and "fba8c1f2f41c7b3aba2b8b9f1f5c2d829518d3a5" have entirely different histories.
7ae98d8353
...
fba8c1f2f4
2
Makefile
2
Makefile
@ -26,7 +26,7 @@ all:${MAIN_ROM}
|
|||||||
|
|
||||||
first: ${OBJECT_FILES}
|
first: ${OBJECT_FILES}
|
||||||
${QUIET_LINK}
|
${QUIET_LINK}
|
||||||
${Q}gcc -ggdb $^ -fsanitize=address -fsanitize=undefined -fsanitize=leak -lncursesw -ltinfow -lm -o $@
|
${Q}gcc -ggdb $^ -fsanitize=address -fsanitize=undefined -fsanitize=leak -lncursesw -ltinfow -o $@
|
||||||
|
|
||||||
%.rom:%.asm first
|
%.rom:%.asm first
|
||||||
$(QUIET_FAS)
|
$(QUIET_FAS)
|
||||||
|
28
assembly.c
28
assembly.c
@ -112,10 +112,6 @@
|
|||||||
// | 14'hC | Floating point addition | YES | operand 1 | operand 2 |
|
// | 14'hC | Floating point addition | YES | operand 1 | operand 2 |
|
||||||
// +-------+---------------------------------------------+--------------+------------+------------+
|
// +-------+---------------------------------------------+--------------+------------+------------+
|
||||||
// | 14'hD | Floating point subtraction | YES | operand 1 | operand 2 |
|
// | 14'hD | Floating point subtraction | YES | operand 1 | operand 2 |
|
||||||
// +-------+---------------------------------------------+--------------+------------+------------+
|
|
||||||
// | 14'hE | Calculate the sin of a register | YES | operand | |
|
|
||||||
// +-------+---------------------------------------------+--------------+------------+------------+
|
|
||||||
// | 14'hF | Calculate the cos of a register | YES | operand | |
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// INSTRUCTION FORMAT 2 OPCODE NUM:
|
// INSTRUCTION FORMAT 2 OPCODE NUM:
|
||||||
@ -227,12 +223,6 @@ char *disassemble(uint32_t opcode_be){
|
|||||||
case 0x0D:
|
case 0x0D:
|
||||||
snprintf(ret,MAX_INSTRUCTION_LENGTH,"FSUB %%R%0d,%%R%0d",val1,val2);
|
snprintf(ret,MAX_INSTRUCTION_LENGTH,"FSUB %%R%0d,%%R%0d",val1,val2);
|
||||||
break;
|
break;
|
||||||
case 0x0E:
|
|
||||||
snprintf(ret,MAX_INSTRUCTION_LENGTH,"SIN %%R%0d",val1);
|
|
||||||
break;
|
|
||||||
case 0x0F:
|
|
||||||
snprintf(ret,MAX_INSTRUCTION_LENGTH,"COS %%R%0d",val1);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
snprintf(ret,MAX_INSTRUCTION_LENGTH,"UNRECOGNISED INSTRUCTION");
|
snprintf(ret,MAX_INSTRUCTION_LENGTH,"UNRECOGNISED INSTRUCTION");
|
||||||
break;
|
break;
|
||||||
@ -426,29 +416,21 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
|||||||
opcode=0x2004;
|
opcode=0x2004;
|
||||||
params=2;
|
params=2;
|
||||||
}else if(strncmp(line,"FDIV ",5)==0){
|
}else if(strncmp(line,"FDIV ",5)==0){
|
||||||
x=4;
|
x=5;
|
||||||
opcode=0x200A;
|
opcode=0x200A;
|
||||||
params=2;
|
params=2;
|
||||||
}else if(strncmp(line,"FMUL ",5)==0){
|
}else if(strncmp(line,"FMUL ",5)==0){
|
||||||
x=4;
|
x=5;
|
||||||
opcode=0x200B;
|
opcode=0x200B;
|
||||||
params=2;
|
params=2;
|
||||||
}else if(strncmp(line,"FADD ",5)==0){
|
}else if(strncmp(line,"FADD ",5)==0){
|
||||||
x=4;
|
x=5;
|
||||||
opcode=0x200C;
|
opcode=0x200C;
|
||||||
params=2;
|
params=2;
|
||||||
}else if(strncmp(line,"FSUB ",5)==0){
|
}else if(strncmp(line,"FSUB ",5)==0){
|
||||||
x=4;
|
x=5;
|
||||||
opcode=0x200D;
|
opcode=0x200D;
|
||||||
params=2;
|
params=2;
|
||||||
}else if(strncmp(line,"SIN ",4)==0){
|
|
||||||
x=3;
|
|
||||||
opcode=0x200E;
|
|
||||||
params=1;
|
|
||||||
}else if(strncmp(line,"COS ",4)==0){
|
|
||||||
x=3;
|
|
||||||
opcode=0x200F;
|
|
||||||
params=1;
|
|
||||||
}else
|
}else
|
||||||
params=0;
|
params=0;
|
||||||
if(params!=0){
|
if(params!=0){
|
||||||
@ -481,7 +463,7 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
|||||||
}else
|
}else
|
||||||
return -2;
|
return -2;
|
||||||
}else
|
}else
|
||||||
return (opcode<<16)|r0<<8;
|
return (opcode<<16)|r0<<2;
|
||||||
}else
|
}else
|
||||||
return -2;
|
return -2;
|
||||||
}else
|
}else
|
||||||
|
19
cpu.c
19
cpu.c
@ -1,7 +1,6 @@
|
|||||||
#include "simdata.h"
|
#include "simdata.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -95,8 +94,6 @@ int decode(struct simdata_t *simdata){
|
|||||||
case 0x0B:
|
case 0x0B:
|
||||||
case 0x0C:
|
case 0x0C:
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
case 0x0E:
|
|
||||||
case 0x0F:
|
|
||||||
simdata->exec_data->in_op1->OP_ADDR=REGISTER;
|
simdata->exec_data->in_op1->OP_ADDR=REGISTER;
|
||||||
simdata->exec_data->in_op2->OP_ADDR=REGISTER;
|
simdata->exec_data->in_op2->OP_ADDR=REGISTER;
|
||||||
break;
|
break;
|
||||||
@ -140,10 +137,8 @@ int decode(struct simdata_t *simdata){
|
|||||||
simdata->exec_data->out_op->OP_ADDR=REGISTER;
|
simdata->exec_data->out_op->OP_ADDR=REGISTER;
|
||||||
simdata->exec_data->out_op->data=op2;
|
simdata->exec_data->out_op->data=op2;
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 2:
|
||||||
case 0x03:
|
case 3:
|
||||||
case 0x0E:
|
|
||||||
case 0x0F:
|
|
||||||
simdata->exec_data->out_op->OP_ADDR=REGISTER;
|
simdata->exec_data->out_op->OP_ADDR=REGISTER;
|
||||||
simdata->exec_data->out_op->data=op1;
|
simdata->exec_data->out_op->data=op1;
|
||||||
break;
|
break;
|
||||||
@ -174,8 +169,6 @@ int decode(struct simdata_t *simdata){
|
|||||||
case 0x0B: simdata->exec_data->ALU_OP=ALU_FMUL; break;
|
case 0x0B: simdata->exec_data->ALU_OP=ALU_FMUL; break;
|
||||||
case 0x0C: simdata->exec_data->ALU_OP=ALU_FADD; break;
|
case 0x0C: simdata->exec_data->ALU_OP=ALU_FADD; break;
|
||||||
case 0x0D: simdata->exec_data->ALU_OP=ALU_FSUB; break;
|
case 0x0D: simdata->exec_data->ALU_OP=ALU_FSUB; break;
|
||||||
case 0x0E: simdata->exec_data->ALU_OP=ALU_FSIN; break;
|
|
||||||
case 0x0F: simdata->exec_data->ALU_OP=ALU_FCOS; break;
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -319,12 +312,6 @@ int exec(struct simdata_t *simdata){
|
|||||||
*(float*)&result = *(float*)(&simdata->registers->GPR[simdata->exec_data->in_op2->data])-
|
*(float*)&result = *(float*)(&simdata->registers->GPR[simdata->exec_data->in_op2->data])-
|
||||||
*(float*)(&simdata->registers->GPR[simdata->exec_data->in_op1->data]);
|
*(float*)(&simdata->registers->GPR[simdata->exec_data->in_op1->data]);
|
||||||
break;
|
break;
|
||||||
case ALU_FSIN:
|
|
||||||
*(float*)&result = sinf(*(float*)(&simdata->registers->GPR[simdata->exec_data->in_op1->data]));
|
|
||||||
break;
|
|
||||||
case ALU_FCOS:
|
|
||||||
*(float*)&result = cosf(*(float*)(&simdata->registers->GPR[simdata->exec_data->in_op1->data]));
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -393,7 +380,6 @@ int exec(struct simdata_t *simdata){
|
|||||||
simdata->RAM[simdata->registers->SP ]=simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x000000FF;
|
simdata->RAM[simdata->registers->SP ]=simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x000000FF;
|
||||||
simdata->RAM[simdata->registers->SP+1]=(simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x0000FF00)>>8;
|
simdata->RAM[simdata->registers->SP+1]=(simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x0000FF00)>>8;
|
||||||
simdata->RAM[simdata->registers->SP+2]=(simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x00FF0000)>>16;
|
simdata->RAM[simdata->registers->SP+2]=(simdata->registers->GPR[simdata->exec_data->in_op1->data]&0x00FF0000)>>16;
|
||||||
simdata->RAM[simdata->registers->SP+3]=(simdata->registers->GPR[simdata->exec_data->in_op1->data]&0xFF000000)>>24;
|
|
||||||
simdata->registers->SP+=4;
|
simdata->registers->SP+=4;
|
||||||
break;
|
break;
|
||||||
case POP:
|
case POP:
|
||||||
@ -401,7 +387,6 @@ int exec(struct simdata_t *simdata){
|
|||||||
simdata->registers->GPR[simdata->exec_data->in_op1->data]=simdata->RAM[simdata->registers->SP];
|
simdata->registers->GPR[simdata->exec_data->in_op1->data]=simdata->RAM[simdata->registers->SP];
|
||||||
simdata->registers->GPR[simdata->exec_data->in_op1->data]|=simdata->RAM[simdata->registers->SP+1]<<8;
|
simdata->registers->GPR[simdata->exec_data->in_op1->data]|=simdata->RAM[simdata->registers->SP+1]<<8;
|
||||||
simdata->registers->GPR[simdata->exec_data->in_op1->data]|=simdata->RAM[simdata->registers->SP+2]<<16;
|
simdata->registers->GPR[simdata->exec_data->in_op1->data]|=simdata->RAM[simdata->registers->SP+2]<<16;
|
||||||
simdata->registers->GPR[simdata->exec_data->in_op1->data]|=simdata->RAM[simdata->registers->SP+3]<<24;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_to_instr_list(&simdata->cpu_gui_hints->executing_list,simdata->exec_data->address);
|
add_to_instr_list(&simdata->cpu_gui_hints->executing_list,simdata->exec_data->address);
|
||||||
|
Loading…
Reference in New Issue
Block a user