2021-01-29 14:17:59 -05:00
|
|
|
#include <stdio.h>
|
2021-02-08 15:16:39 -05:00
|
|
|
#include "cpu.h"
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-01-29 14:35:59 -05:00
|
|
|
/*
|
2021-01-29 14:17:59 -05:00
|
|
|
Copyright (c) 2021 Devine Lu Linvega
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2021-01-29 15:14:37 -05:00
|
|
|
FILE *f;
|
2021-02-08 16:56:56 -05:00
|
|
|
Cpu cpu;
|
2021-01-29 15:14:37 -05:00
|
|
|
if(argc < 2)
|
2021-02-08 16:56:56 -05:00
|
|
|
return error(&cpu, "No input.", 0);
|
2021-01-29 15:14:37 -05:00
|
|
|
if(!(f = fopen(argv[1], "rb")))
|
2021-02-08 16:56:56 -05:00
|
|
|
return error(&cpu, "Missing input.", 0);
|
|
|
|
if(!load(&cpu, f))
|
|
|
|
return error(&cpu, "Load error", 0);
|
|
|
|
if(!boot(&cpu))
|
|
|
|
return error(&cpu, "Boot error", 0);
|
2021-01-29 15:14:37 -05:00
|
|
|
/* print result */
|
2021-02-04 16:49:03 -05:00
|
|
|
echos(&cpu.wst, 0x40, "stack");
|
|
|
|
echom(&cpu.ram, 0x40, "ram");
|
2021-02-08 16:56:56 -05:00
|
|
|
echof(&cpu);
|
2021-01-29 14:17:59 -05:00
|
|
|
return 0;
|
|
|
|
}
|