Compare commits
No commits in common. "e5705a8477a7cd8024d2d932c2a9ddeac9400a33" and "2d4c021130ad0e22bbf5fd2694d3634c650adaf2" have entirely different histories.
e5705a8477
...
2d4c021130
2
cpu.c
2
cpu.c
@ -123,7 +123,6 @@ int cpu_simdata_malloc(struct simdata_t *simdata){
|
||||
simdata->fetch_data=malloc_fetch_data();
|
||||
simdata->decode_data=malloc_decode_data();
|
||||
simdata->exec_data=malloc_exec_data();
|
||||
simdata->registers=malloc(sizeof(struct registers_t));
|
||||
if((simdata->fetch_data!=NULL)&&(simdata->decode_data!=NULL)&&(simdata->exec_data!=NULL))
|
||||
return 1;
|
||||
else
|
||||
@ -134,5 +133,4 @@ void cpu_simdata_free(struct simdata_t *simdata){
|
||||
free_fetch_data(simdata->fetch_data);
|
||||
free_decode_data(simdata->decode_data);
|
||||
free_exec_data(simdata->exec_data);
|
||||
free(simdata->registers);
|
||||
}
|
||||
|
14
cpu.h
14
cpu.h
@ -50,19 +50,5 @@ void cpu_simdata_free(struct simdata_t *simdata);
|
||||
int cpu_simdata_malloc(struct simdata_t *simdata);
|
||||
int cpu_cycle_clock(struct simdata_t *simdata);
|
||||
|
||||
// +===================+
|
||||
// | BIT | USAGE |
|
||||
// |-----+-------------|
|
||||
// | 0 | ZERO |
|
||||
// |-----+-------------|
|
||||
// | 1 | CARRY |
|
||||
// |-----+-------------|
|
||||
// | 2 | SIGN |
|
||||
//
|
||||
struct registers_t{
|
||||
uint32_t GPR[8];
|
||||
uint32_t FLAGS;
|
||||
};
|
||||
|
||||
#endif
|
||||
#define CPU_HEADER
|
||||
|
126
gui.c
126
gui.c
@ -22,7 +22,6 @@
|
||||
#include "simdata.h"
|
||||
#include "assembly.h"
|
||||
#include <stdlib.h>
|
||||
#include "cpu.h"
|
||||
|
||||
#define GENERAL_STACK_MAX_WIDTH 16
|
||||
#define GENERAL_DISAS_WIDTH 41
|
||||
@ -34,7 +33,6 @@ WINDOW *tabs;
|
||||
WINDOW *general_memdump;
|
||||
WINDOW *general_stack;
|
||||
WINDOW *general_disas;
|
||||
WINDOW *general_registers;
|
||||
|
||||
int monochrome;
|
||||
|
||||
@ -58,8 +56,6 @@ int gui_ncurses_refresh(){
|
||||
return 1;
|
||||
if(wrefresh(general_disas)==ERR)
|
||||
return 1;
|
||||
if(wrefresh(general_registers)==ERR)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -136,38 +132,21 @@ int start_gui(){
|
||||
tabs = newwin(1,terminal_width,0,0);
|
||||
update_tabs();
|
||||
int len;
|
||||
|
||||
int y1_divider;
|
||||
|
||||
int border=4;
|
||||
|
||||
if( (terminal_height-2*border)*0.2 < 8 )
|
||||
y1_divider=terminal_height-border-8;
|
||||
else if ( ( terminal_height - 2*border )*0.2 < 15 )
|
||||
y1_divider=terminal_height-border-11;
|
||||
else
|
||||
y1_divider=(terminal_height-border*2)*0.8;
|
||||
|
||||
int x=border;
|
||||
|
||||
general_memdump=newwin(y1_divider,terminal_width/2,x,border);
|
||||
int x=4;
|
||||
general_memdump=newwin(terminal_height*0.8,terminal_width/2,x,5);
|
||||
x+=terminal_width/2;
|
||||
x++;
|
||||
|
||||
x+=3;
|
||||
len=(terminal_width/6)>GENERAL_DISAS_WIDTH?GENERAL_DISAS_WIDTH:(terminal_width/6);
|
||||
general_disas=newwin(y1_divider,len,4,x);
|
||||
general_disas=newwin(terminal_height*0.8,len,4,x);
|
||||
x+=len;
|
||||
|
||||
x+=3;
|
||||
len=(terminal_width/6)>GENERAL_STACK_MAX_WIDTH?GENERAL_STACK_MAX_WIDTH:(terminal_width/6);
|
||||
general_stack=newwin(y1_divider,len,4,x);
|
||||
general_stack=newwin(terminal_height*0.8,len,4,x);
|
||||
x+=len;
|
||||
|
||||
general_registers=newwin(terminal_height-y1_divider-border-1,terminal_width/2,y1_divider+border+1,border);
|
||||
x+=terminal_width/2;
|
||||
x++;
|
||||
|
||||
if(gui_ncurses_refresh())
|
||||
return 1;
|
||||
return 0;
|
||||
@ -334,62 +313,6 @@ int update_general_memdump(struct simdata_t *simdata){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int update_general_registers(struct simdata_t *simdata){
|
||||
int width,height;
|
||||
getmaxyx(general_registers,height,width);
|
||||
box(general_registers, 0 , 0);
|
||||
mvwprintw(general_registers,0,terminal_width/4-7,"[ REGISTERS ]");
|
||||
if(simdata->registers==NULL)
|
||||
mvwprintw(general_registers,1,1,"Registers data structure not initialised");
|
||||
else{
|
||||
int per_line=width/35;
|
||||
if(per_line==0)
|
||||
mvwprintw(general_registers,1,1,"too small window");
|
||||
else{
|
||||
int center_x_offset=((width-2)-35*per_line)/2;
|
||||
int lines_used=(8/(int)per_line<8/(float)per_line)?8/per_line+1:8/per_line;
|
||||
int center_y_offset=((height-2)-(lines_used+2))/2;
|
||||
|
||||
if((lines_used+2)>(height-2)||width<37)
|
||||
mvwprintw(general_registers,1,1,"too small window");
|
||||
else{
|
||||
int n=0,y=0;
|
||||
while(y!=lines_used){
|
||||
for(int i=0;i<per_line;i++){
|
||||
if(n<8){
|
||||
mvwprintw(general_registers,1+y+center_y_offset,1+i*35+center_x_offset,"R%d: %08X (%lf) ",n,simdata->registers->GPR[n],(double)simdata->registers->GPR[n]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
y++;
|
||||
}
|
||||
|
||||
for(int i=0;i<35*per_line;i++)
|
||||
mvwaddch(general_registers,1+center_y_offset+lines_used,center_x_offset+i,ACS_HLINE);
|
||||
|
||||
wattron(general_registers,A_BOLD);
|
||||
mvwprintw(general_registers,1+center_y_offset+lines_used+1,1+center_x_offset," ZERO");
|
||||
wattroff(general_registers,A_BOLD);
|
||||
wprintw(general_registers,": %c ",(simdata->registers->FLAGS&1)?'1':'0');
|
||||
|
||||
wattron(general_registers,A_BOLD);
|
||||
wprintw(general_registers,"CARRY");
|
||||
wattroff(general_registers,A_BOLD);
|
||||
wprintw(general_registers,": %c ",(simdata->registers->FLAGS&2)?'1':'0');
|
||||
|
||||
wattron(general_registers,A_BOLD);
|
||||
wprintw(general_registers,"SIGN");
|
||||
wattroff(general_registers,A_BOLD);
|
||||
wprintw(general_registers,": %c ",(simdata->registers->FLAGS&4)?'1':'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
if(height!=34242321)
|
||||
return 0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clear_back_window=1;
|
||||
|
||||
int update_gui(struct simdata_t *simdata){
|
||||
@ -404,8 +327,6 @@ int update_gui(struct simdata_t *simdata){
|
||||
return 1;
|
||||
if(update_general_disas(simdata))
|
||||
return 1;
|
||||
if(update_general_registers(simdata))
|
||||
return 1;
|
||||
if(gui_ncurses_refresh())
|
||||
return 1;
|
||||
return 0;
|
||||
@ -413,31 +334,20 @@ int update_gui(struct simdata_t *simdata){
|
||||
|
||||
int gui_continue_request(){
|
||||
char inch;
|
||||
int release=0;
|
||||
while(release==0){
|
||||
if(((inch=getch())==ERR)){
|
||||
if(CPU_STATE==SINGLE_STEPPING)
|
||||
return 1;
|
||||
else
|
||||
release=1;
|
||||
}
|
||||
switch(inch){
|
||||
case 'r':
|
||||
if(CPU_STATE==RUNNING){
|
||||
CPU_STATE=SINGLE_STEPPING;
|
||||
nodelay(stdscr, FALSE);
|
||||
}else{
|
||||
CPU_STATE=RUNNING;
|
||||
nodelay(stdscr, TRUE);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
return 2;
|
||||
case '\n':
|
||||
release=1;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
if(((inch=getch())==ERR)&&CPU_STATE==SINGLE_STEPPING)
|
||||
return 1;
|
||||
switch(inch){
|
||||
case 'r':
|
||||
if(CPU_STATE==RUNNING){
|
||||
CPU_STATE=SINGLE_STEPPING;
|
||||
nodelay(stdscr, FALSE);
|
||||
}else{
|
||||
CPU_STATE=RUNNING;
|
||||
nodelay(stdscr, TRUE);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ struct simdata_t *init_simdata(){
|
||||
|
||||
ret->PC=0;
|
||||
ret->SP=0;
|
||||
ret->registers=NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user