- added syscall read
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@786 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdio.h>
|
||||||
#include "libsys.h"
|
#include "libsys.h"
|
||||||
#include "xcpt.h"
|
#include "xcpt.h"
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ char *itoa(int i)
|
|||||||
int syscalls_handler(struct xcptcontext * xcp)
|
int syscalls_handler(struct xcptcontext * xcp)
|
||||||
{
|
{
|
||||||
int syscall_code;
|
int syscall_code;
|
||||||
char *pStr;
|
char *pStr, buf[33];
|
||||||
|
|
||||||
syscall_code = xcp->regs[2];
|
syscall_code = xcp->regs[2];
|
||||||
|
|
||||||
@@ -54,8 +55,22 @@ int syscalls_handler(struct xcptcontext * xcp)
|
|||||||
sputs(pStr);
|
sputs(pStr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 5: // read integer
|
||||||
|
pStr = fgets(buf, sizeof(buf), stdin);
|
||||||
|
xcp->regs[2] = atoi(pStr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8: // read string
|
||||||
|
pStr = (char*)xcp->regs[4];
|
||||||
|
fgets(pStr, xcp->regs[5], stdin);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10: // exit
|
||||||
|
_exit(0);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sputs("Unknown syscall (");print_word(syscall_code);sputs(") at ");print_word(xcp->epc);sputs("\n");
|
sputs("\nUnknown syscall (");print_word(syscall_code);sputs(") at ");print_word(xcp->epc);sputs("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user