71 lines
2.0 KiB
C
71 lines
2.0 KiB
C
#include "proc.h"
|
|
#include "linker.h"
|
|
#include "../common/graph.h"
|
|
#include "../common/event.h"
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
Platform_init();
|
|
if(argc==2) {
|
|
//init processor
|
|
proc_t proc;
|
|
initProc(&proc);
|
|
|
|
//link the file given in argument
|
|
if(!Linker_link(argv[1], &proc)) {
|
|
fprintf(stderr, "Can not link file\n");
|
|
fprintf(stderr, "Error: %d\n", Platform_getError());
|
|
Platform_quit();
|
|
return 1;
|
|
} else {
|
|
printf("Linked the program\n");
|
|
}
|
|
|
|
//run the program
|
|
Proc_execute(&proc, -1);
|
|
printf("Ran the program\n");
|
|
|
|
//dump proc status
|
|
printf("Proc status:\n");
|
|
printf("\tRegisters:\n");
|
|
for(int i=0; i<256; i++) {
|
|
if(proc.registers[i].i) printf("\t\t#%.2x:\t0x%.8x\t%f\t%d\n", i, proc.registers[i].i, proc.registers[i].d, proc.registers[i].i);
|
|
}
|
|
printf("\tInterrupt handler:\t0x%.8x\n", proc.intHandler);
|
|
printf("\tSubscribed interrupts:\t0x%.8x\n", proc.subscribed);
|
|
printf("\tStatus register:\t0x%.8x\n", proc.status);
|
|
printf("\tLast address:\t0x%.8x\n", proc.lastAddress);
|
|
printf("\tStack: %d\n", proc.stack.top);
|
|
for(int i=0; i<proc.stack.top; i++) {
|
|
printf("\t\t#%.2x:\t0x%.8x\t%f\n", i, proc.stack.elements[i].i, proc.stack.elements[i].d);
|
|
}
|
|
|
|
//dump the MMU configuration
|
|
printf("MMU status:\n");
|
|
printf("\tMappings: %d\n", proc.mmu.length);
|
|
for(int i=0; i<proc.mmu.length; i++) {
|
|
memory_map_t map=proc.mmu.segments[i];
|
|
printf("\t\tPos: %.8x; Len: %.8x; Access: %o; Info: %.2x\n", map.pos, map.len, map.access, map.info);
|
|
}
|
|
printf("\tError action: %x\n", proc.mmu.onError);
|
|
|
|
//cleanup everything
|
|
Segments_unmapAll(&proc.mmu);
|
|
} else {
|
|
for(int i=0; i<16; i++) {
|
|
Graph_lineH(i, i, i+2, COLOR_BLACK);
|
|
Graph_lineH(i+16, i, i+3, COLOR_BLACK);
|
|
Graph_lineH(i+32, i, i+4, COLOR_BLACK);
|
|
Graph_lineH(i+48, i, i+5, COLOR_BLACK);
|
|
}
|
|
|
|
Graph_printVram();
|
|
|
|
event_t evt;
|
|
Event_wait(&evt);
|
|
printf("Event type is %d and subtype is %d; code is %d\n", evt.type, evt.subtype, evt.keyevent.code);
|
|
}
|
|
|
|
Platform_quit();
|
|
}
|