summaryrefslogtreecommitdiffstats
path: root/newlib/libc/sys/h8300hms/read.c
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2002-05-17 20:13:38 +0000
committerThomas Fitzsimmons <fitzsim@redhat.com>2002-05-17 20:13:38 +0000
commit7fc85bd1b9502b5fe30102e85f4743dbf45b9f01 (patch)
treebdfe520d8183ba54c11e0fcbb846b453a36f0364 /newlib/libc/sys/h8300hms/read.c
parentb05b7d84d6bd29dd07d0b493dad8d4d48493db3e (diff)
downloadcygnal-7fc85bd1b9502b5fe30102e85f4743dbf45b9f01.tar.gz
cygnal-7fc85bd1b9502b5fe30102e85f4743dbf45b9f01.tar.bz2
cygnal-7fc85bd1b9502b5fe30102e85f4743dbf45b9f01.zip
* newlib/libc/sys/h8300hms/Makeile.am (lib_a_SOURCES): Add read.c.
* newlib/libc/sys/h8300hms/read.c: New file. Magic trap 0xC8 for sim. * newlib/libc/sys/h8300hms/syscalls.c: Move _read() to read.c. * newlib/libs/sys/h8300hms/sys/syscall.h: New file.
Diffstat (limited to 'newlib/libc/sys/h8300hms/read.c')
-rw-r--r--newlib/libc/sys/h8300hms/read.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/newlib/libc/sys/h8300hms/read.c b/newlib/libc/sys/h8300hms/read.c
new file mode 100644
index 000000000..ba6b9e929
--- /dev/null
+++ b/newlib/libc/sys/h8300hms/read.c
@@ -0,0 +1,27 @@
+#include "sys/syscall.h"
+
+int _read(file, ptr, len)
+ int file;
+ char *ptr;
+ int len;
+{
+ register int ret asm("r0") ;
+
+ /* Type cast int as short so that we can copy int values into 16 bit
+ registers in case of -mint32 switch is given.
+ This is not going to affect data as file= 0 for stdin and len=1024 */
+
+ asm("mov.b %0, r0l":: "i" (SYS_read)) ; /* Syscall Number */
+ asm("mov.w %0, r1" :: "r"((short)file) :"r1", "r2", "r3") ;
+ asm("mov.w %0, r3" :: "r"((short)len) :"r1", "r2", "r3") ;
+#ifdef __H8300__
+ asm("mov.w %0, r2" :: "r"(ptr) :"r1", "r2", "r3") ;
+#else
+ asm("mov.l %0, er2" :: "r"(ptr) :"r1", "er2", "r3") ;
+#endif
+ // This is magic trap similar to _write for simulator
+ asm("jsr @@0xc8") ;
+ return ret;
+}
+
+