Welcome to mirror list, hosted at ThFree Co, Russian Federation.

read.c « h8300hms « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba6b9e92906f6e8dd53ccac8bc0e1ab560ce3ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}