- 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:
2010-03-13 13:51:42 +00:00
parent 8971cdc872
commit ed483b2e03
+17 -2
View File
@@ -1,3 +1,4 @@
#include <stdio.h>
#include "libsys.h"
#include "xcpt.h"
@@ -39,7 +40,7 @@ char *itoa(int i)
int syscalls_handler(struct xcptcontext * xcp)
{
int syscall_code;
char *pStr;
char *pStr, buf[33];
syscall_code = xcp->regs[2];
@@ -54,8 +55,22 @@ int syscalls_handler(struct xcptcontext * xcp)
sputs(pStr);
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:
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;
}